I have a feature class that I need to compare two of each feature and the two fields have the same info, I want to delete them. I have some code that works for the table but I know that working with spatial data I may get inconsistent results. I made the following but I am uncertain I am dong it correctly, and I don't get any errors.
import arcpy
fc = r'C:\Temp\test.shp'
fields = ['OID@', 'PN', 'ACT', 'ACRES']
# if need just two field use ['OID@','PN', 'ACT']
sort_field, sort_order = "OBJECTID", "ASC"
fields = fields
sql_orderby = "ORDER BY {}, {} {}".format(", ".join(fields), sort_field, sort_order)
table_rows = []
with arcpy.da.UpdateCursor(fc, fields, sql_clause=(None, sql_orderby)) as cursor:
for row in cursor:
if row[1:] in table_rows:
cursor.deleteRow()
else:
pass
table_rows.append(row[1:])
del table_rows
I would also like to see if I can use the same code to update a field "Duplicate" with the text "Dup", if they are duplicates, so I can double check that the correct features are being deleted on a copy of the feature class.