Last active
January 31, 2019 20:41
-
-
Save jasonbot/3100381 to your computer and use it in GitHub Desktop.
Get dicts instead of lists from an arcpy.da SearchCursor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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