English
Continue in the app
Be The First To Get Support Updates
Want to know about the latest technical content and software updates?

FAQ: How can I check for null values in the Field Calculator using Python?

Question

How can I check for null values in the Field Calculator using Python?

Answer

Starting at ArcGIS for Desktop 10.1, null values in an attribute table are returned as the string 'None' in the Field Calculator using Python. Knowing this, an if/elif statement can be used to find whether values are null or not. Here is an example script that checks if a field contains null values:

Expression:
findNulls(!fieldA!)

Expression Type:
PYTHON_9.3

Code Block:
def findNulls(fieldValue):
    if fieldValue is None:
        return "null values"
    elif fieldValue is not None:
        return "no nulls here"

Related Information

Last Published: 11/16/2021

Article ID: 000011740

Software: ArcGIS for Desktop Advanced 10.1 ArcGIS for Desktop Basic 10.1 ArcGIS for Desktop Standard 10.1