Can't seem to figure this one out. I'm calculating a field with the field calculator, but not every row is populated with a value. Only about half are populated and the rest of the rows are Null. I tried to define a python function to replace the Null values with 0, but no luck so far. It looks something like this:
if x is Null:
I suppose I should have used an update cursor? As a work around I populated the entire field with a value of 0 before doing my real calc. That filled in the gaps, but I'd still like to figure this out.
Well, I just used the word "null" in the name of the function. It actually runs without any gp errors/results, but nothing happens. I'm guessing an if statement wasn't the right way to go. Maybe an update cursor? or could I have converted the field to a string, used .replace(), then converted back to an integer?
Oh, duh. I see what you're saying. What I MEANT to say was.. yup, I did switch over to the word None after digging through the forums a bit. Then, it runs but nothing happens. The conclusion I've come to is that my approach was all wrong in the first place.
a) simplest solution was to populate the whole field with a value of 0 first. b) if I wanted to hunt for values of None row by row, then using an update cursor in a stand alone script would likely be the way to go.