Guest User

Untitled

a guest
Sep 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. import arcpy
  2. feature_class = 'C:data.gdbfeatures123' #Change
  3. field_to_update = 'somefield' #Change
  4. values = [1,2,3,4] #Change
  5.  
  6. list_iterator = iter(values)
  7.  
  8. with arcpy.da.UpdateCursor(feature_class, field_to_update) as cursor:
  9. for row in cursor:
  10. try:
  11. row[0] = next(list_iterator) #Assign list value to row[0]/field_to_update
  12. cursor.updateRow(row) #Update the field
  13. except StopIteration: #If you have less items in list than number of rows in feature class
  14. print 'List is empty, cant update any more rows'
Add Comment
Please, Sign In to add comment