carkxg

CalculateField expression looking for null values

Discussion created by carkxg on Mar 21, 2011
I have a feature class in a file geodatabase called 'TxtP' and I am trying to update an attribute called ANNOSYMBOL based on its current value. I have tried:

arcpy.CalculateField_management(TxtP_lyr, "ANNOSYMBOL", "0 if !ANNOSYMBOL! == 25 else !ANNOSYMBOL!", "PYTHON_9.3", "")

This code looks in the value for ANNOSYMBOL and if the value is 25 then it calculates it to 0 otherwise it leaves it as it is. This works fine.

What I really want the code to do is look for any values which are <null> (None in Python) and convert them to zero. So the code would be:

arcpy.CalculateField_management(TxtP_lyr, "ANNOSYMBOL", "0 if !ANNOSYMBOL! is None else !ANNOSYMBOL!", "PYTHON_9.3", "")

But this doesn't work. I've tried '== None' as well as 'is None' with no luck. Any help would be great, thanks.

Outcomes