I'm trying to fill a blank field depending on the contents of three other fields using python in the field calculator.
Sample code is something like:
def getClass(Text1,Text2,Text3):
if Text1 is None:
return Text2
elif Text2 is None:
return Text3
else:
return Text1
I can retrieve the value of the first field but never the 2nd two. I know this isn't the right way but I can't figure out the nesting levels... Any ideas?
UPDATE: Fixed by stripping out the white space. Credit to this post Using Calculate Field tool to calculate on null fields?
def getClass(Text1,Text2,Text3):
if Text1.strip():
x = Text1
elif Text2.strip():
x = Text2
elif Text3.strip():
x = Text3
else:
x = "NA";
return x