Skip to content

Instantly share code, notes, and snippets.

@jasonbot
Last active January 31, 2019 20:41
Show Gist options
  • Save jasonbot/3100381 to your computer and use it in GitHub Desktop.
Save jasonbot/3100381 to your computer and use it in GitHub Desktop.
Get dicts instead of lists from an arcpy.da SearchCursor
def rows_as_dicts(cursor):
colnames = cursor.fields
for row in cursor:
yield dict(zip(colnames, row))
with arcpy.da.SearchCursor(r'c:\data\world.gdb\world_cities', '*') as sc:
for row in rows_as_dicts(sc):
print row['CITY_NAME']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment