Skip to content

Instantly share code, notes, and snippets.

@danmaps
Last active September 24, 2020 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danmaps/b3bb0f77a43d89a1fa3f7f7ef8ed88de to your computer and use it in GitHub Desktop.
Save danmaps/b3bb0f77a43d89a1fa3f7f7ef8ed88de to your computer and use it in GitHub Desktop.
import arcpy
fc1 = 'buildings'
fc2 = 'buildings_1'
fields1 = ['osm_id', 'type']
fields2 = ['osm_id', 'test']
libraries = []
# loop through each row in fc1 and add the osm_id to the libraries list
with arcpy.da.SearchCursor(fc1, fields1) as search_cursor:
for row in search_cursor:
if row[1] == 'library':
# print(u'{0}, {1}'.format(row[0], row[1]))
libraries.append(row[1])
# loop through each row in fc2 and update the 'test' field if the corresponding osm_id is in the libraries list
with arcpy.da.UpdateCursor(fc2, fields2) as update_cursor:
for row in update_cursor:
if row[0] in libraries:
row[1] = 'this is a library'
update_cursor.updateRow(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment