I'm using Arc 10.2.2.
I have 2 files:
- "Input_Table.exe" (only 3 columns: "ID", "Lat", and "Lon")
- "Target_Shapefile.shp" (many columns including the same "ID", "Lat", and "Lon")
Any rows in the Target_Shapefile with an ID that's present in the Input_Table need to be updated with those appropriate values.
I'm aware of the Update Cursor and that using its 3rd parameter, the "Where Clause", will reduce the number of retrieved rows to be updated, thus saving time.
But how do I refer to a row in the same shapefile that's being updated? (Target_Shapefile)
More specifically, is the following syntax for my "Where Clause" valid?
Where = "Where ['ID'] in Input_ID_list"
My Complete Code:
# Create a list of all IDs to be updated in the Target_Shapefile. rows = arcpy.da.SearchCursor(Input_Table) for row in rows: Input_ID = row.getValue('ID') Input_ID_list = Input_ID_list + Input_ID # Set "Where Clause" Where = "Where ['ID'] in Input_ID_list" # Create the Update Cursor... with arcpy.da.UpdateCursor(Target_Shapefile,['ID', 'Lat', 'Lon'] , Where) as Tcursor: for row in Tcursor: do some things...