Delete records in feature class that have same ID in CSV table using arcpy cursors

المشرف العام

Administrator
طاقم الإدارة
So I have a csv table with records that have an ID. I want to find the same IDs in a feature class/shapefile and delete those records in the feature class/shapefile using Python.

I've messed with add.join and relates without a good result so I figured I'd move to cursors. I've setup two search cursors to test the result but I don't think the logic is quite right so I'm posing my question here.

Here's a code snippet. The second cursor will eventually change to Update.Cursor using delete row but not until I get the result correct first.

import arcpytc = "d:\\temp\\tc.shp"changes = "d:\\temp\\changes.csv"with arcpy.da.SearchCursor(changes,"RECORDNUM_AFTER") as changecur: for row in changecur: changeIDs=rowtcur = arcpy.SearchCursor(tc, fields="RECORDNUM")for row in tcur: if row in changeIDs: print row.getValue("RECORDNUM")

أكثر...
 
أعلى