I'm using a Python script with ArcGIS 10 to count the number of unique string values in a feature class. My script works if there are values in the field but if there are any NUll values in the field it crashes. Any Ideas?
My code is below:
import arcpy
import operator
inTable = arcpy.GetParameterAsText(0)
stringField = arcpy.GetParameterAsText(1)
stringList = [row.getValue(stringField) for row in arcpy.SearchCursor
(inTable, "", "",stringField)]
2 Answers 2
Null values are equal to the python None so you could also handle null values like this
if row.getValue(stringField) == None:
do something
if row.getValue(stringField) != None:
do something else
Use isNull(field_name) method before getting values. For further info see this help topic
-
Do you mean I need to count the null values seperately?user5747– user57472012年02月02日 16:24:05 +00:00Commented Feb 2, 2012 at 16:24
lang-py
None
values, which is the Python representation ofNULL
.