1

I have two columns: "Street1" and "Verified".

I need to check all rows in Street1 to see if they are of string "0" or null. I've attempted to come up with something in Field Calculator but it is returning an error saying the field [Verified] is not nullable

enter image description here

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
TacoB0t
  • 327
  • 4
  • 13

2 Answers2

1

The problem is that you are not explicitly returning any value in the case that your condition(s) are not met. In this case it will implicitly return NULL (None) for any value of "Street1" that is not "0" or None, but NULLs are not permitted in the "Verified" field for which (I'm guessing) you are running this calculation.

You can cater for this by adding an else clause to your if, or just have a default return statement at the end where you make sure you default to returning something other than NULL (or None).

Something like:

def check(street):
    if street is None or street == "0":
        return "V"

    return "X"

(replace "X" with whatever non-"V" value you want - even return "" would be OK)

Alternatively, if you really want NULL values, and the dataset is a GDB that can handle NULL values, you will need to redefine the field properties to allow NULL values for the "Verified" field.

Son of a Beach
  • 8,182
  • 1
  • 17
  • 33
0

This method will replace null, empty or zero values with V. Otherwise it will return the street attribute.

def check(street):
    if street == "":
        return "V"
    elif street == "0":
        return "V"
    elif not street:
        return "V"
    else:
        return street

If you get the same error you'll need to remove (elif not street:/return "V").

jbalk
  • 7,505
  • 1
  • 17
  • 39