Skip to content

Instantly share code, notes, and snippets.

@cindygis
Created December 4, 2015 06:22
Show Gist options
  • Save cindygis/ac1eb4b57f3469109ba2 to your computer and use it in GitHub Desktop.
Save cindygis/ac1eb4b57f3469109ba2 to your computer and use it in GitHub Desktop.
Updates a field using a nested loop in an arcpy update cursor
import arcpy
lyr = arcpy.mapping.Layer(r'C:\Some\Arb\Folder\work.gdb\ftr_test')
cursor = arcpy.da.UpdateCursor(lyr, 'Name')
for i in xrange(10):
for e in ['X', 'Y']:
upd.next() # Increment the cursor
upd.updateRow(['Zone ' + str(i) + e])
# Output
# Zone 1X
# Zone 1Y
# Zone 2X
# etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment