Select to view content in your preferred language

Basic check for Null not working in ArcGIS Pro Field Calculator

484
2
Jump to solution
04-19-2024 09:50 AM
NeoGeo
by
Occasional Contributor III

A super basic check for NULL in ArcGIS Pro Field calculator on a feature layer in ArcGISOnline  does not work on a text field containing an address.  It bombs and deletes all the data in the field or produces an error depending on which way I try to do it.  It does not appear to equate None with NULL either. 

Code:

MrClean(!ADDRESS!)

def MrClean(MyInput):
     if MyInput is None:
          pass
     else:
          return MyInput.strip

 

 

This is what I have tried:

if MyInput is None        No error just wipes out everything in the field because it is not finding the NULL values
if MyInput == None     No error just wipes out everything in the field because it is not finding the NULL values
if isnull(MyInput)           NameError: name 'isnull' is not defined
if MyInput.isnull()          AttributeError: 'str' object has no attribute 'isnull'
if isNull(MyInput)          NameError: name 'isNull' is not defined
if MyInput is NULL        NameError: name 'NULL' is not defined
if MyInput is Null           NameError: name 'NULL' is not defined
if MyInput is null            NameError: name 'NULL' is not defined
if MyInput == ' '             It wipes out everything and only gives this: WARNING 002858: Certain rows set to NULL due to error while evaluating python expression: File "<string>", line 9, in MrClean
if MyInput == null:        NameError: name 'null' is not defined

 

 

 

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

 

MyInput = "  ooops  "
def MrClean(MyInput):
     if MyInput is not None:
          return MyInput.strip()
print(MrClean(None))
None

print(MrClean(MyInput))
ooops

 


... sort of retired...

View solution in original post

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

 

MyInput = "  ooops  "
def MrClean(MyInput):
     if MyInput is not None:
          return MyInput.strip()
print(MrClean(None))
None

print(MrClean(MyInput))
ooops

 


... sort of retired...
0 Kudos
NeoGeo
by
Occasional Contributor III

Thanks so much Dan!  The problem was not the null at all.  It was the syntax error I made where I left out the parenthesis but it did not generate an error.  

0 Kudos