Skip to content

Instantly share code, notes, and snippets.

@knu2xs
Created June 27, 2014 18:26
Show Gist options
  • Select an option

  • Save knu2xs/77ed7a8dc1333f8ffdc5 to your computer and use it in GitHub Desktop.

Select an option

Save knu2xs/77ed7a8dc1333f8ffdc5 to your computer and use it in GitHub Desktop.
Clear fields to null with negative number placeholders in ArcGIS
# import modules
import arcpy
# feature class or table to modify
table = r'path/to/featureClass/or/table'
# create update cursor to interate data
with arcpy.da.UpdateCursor(table, '*') as cursor:
# iterate the rows
for row in cursor:
# value to store the row field index
i = 0
# for every row field
while i < len(row):
# if the value in the field is less than zero
if row[i] < 0:
# set the value to None, or Null
row[i] = None
# increment the index
i = i + 1
# update the row
cursor.updateRow(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment