+1 @Fetzer.
I'm not sure if this is purely a shapefile "phenomenon" (I rarely if ever mess with GDB--they have nullable fields at any rate), but cells that appear to be blank are not really blank.
This can be shown by adding a blank field and then running a field calculator on it, setting the values to "". If you look at the values afterwards, they are actually being stored as single spaces, which can be seen via a cursor or during an edit session.
You can go and delete the space, save your edits, and it will still come back.
If the above code seems to be failing for this reason, you'll need to make a slight adjustment:
Expression:
calc(!FIELD!)
Code Block:
def calc(myField):
if not myField:
return someValue
elif myField == " ":
return someValue
else:
return MyField
If you know that the cells are stored as a true "blank cell" then you can use ternary operators:
def calc(myField):
return someValue if not myField else MyField
or if some cells are stored as a single space:
def calc(myField):
return someValue if myField == " " else MyField
Nullvalues had a 10.0 bug which was fixed at 10.1. If you have any issues in this vicinity at 10.0 then I recommend testing the same code at 10.1/10.2. I came across this here and in my own work recently. – PolyGeo Oct 23 '13 at 04:15