jason.tipton.gis

Python Field Calculator Null Values

Discussion created by jason.tipton.gis on Feb 15, 2011
Latest reply on Feb 22, 2012 by jason.tipton.gis
I am trying to calculate the value of a field based on multiple other fields. My code works fine in Python, but it bombs in ArcPad. The reason must be that I have Null values in a lot of my fields.

Here is a very simplified illustration:

def main (a,b):
  return a


field1 =
 main(1, !field2!)


where !field2! is a field that is Null

I receive no error, it just won't place the calculated "1" into field2. If you were to put:

field1 =
main(1,2)

or
field1 =
main(!field3!, !field4!)

with field3 and field4 holding a non null value, the calculator works as expected. I can't even test for Nulls b/c Python in the Field Calculator apparantly doesn't allow you to access the fields directly in the Codeblock like VBScript would.

Has anyone else ran into this? This seems like it would be a fairly common issue.

Outcomes