I am having difficulty with python parser label function to replace null values with "Unknown Plan" and leave everything else as is. The Unknown Plan is not displaying in the map label.
I have the following:
def FindLabel ( [PLAN] ):
if ([PLAN]) is None:
return "Unknown Plan"
else:
return [PLAN]
Any idea it is not working ?
Solved! Go to Solution.
This will treat NULL and empty strings the same way:
def FindLabel ( [PLAN] ):
if [PLAN] in (None, ""):
return "Unknown Plan"
else:
return [PLAN]
line 2 the ( ) brackets aren't needed
line 3 is indented improperly
Not to ask the obvious, but is the [PLAN] field an empty string instead of NULL?
I made Dan's suggested changes and still no luck.
I should of elaborated what string PLAN field is. The blank fields are Null.
Nulls show up as <Null>, I think you have empty strings.
Good point, I have empty strings, how would I represent empty strings, not Null ?
This will treat NULL and empty strings the same way:
def FindLabel ( [PLAN] ):
if [PLAN] in (None, ""):
return "Unknown Plan"
else:
return [PLAN]
Joshua... fix line 3... it bugs me
Too bad it isn't SE, you could just fix it for me.
def FindLabel ( [PLAN] ):
if [PLAN] in (None, " "):
return "Unknown Plan"
else:
return [PLAN]
This work perfect, thank you. Good to know that an empty string treated the same for label expressions and the field calculator. Null is not though, having to use None to represent Null in label expressions.