I'm trying to use the DeleteIdentical_management tool within an update cursor. I'm pretty sure I'm going about this the wrong way, I'd like to see if someone could help. I'm relatively new to python, so bear with me. Here is my bit of code:

#Delete Identical Features based on Field Name and Rig Number field, not deleting field names with null values.
FC = r'C:\Scripts\Drilling_Rig_Deduplication\Drilling_Rigs.gdb\MERGED_RIGS'
cursor = arcpy.UpdateCursor(FC)
for row in cursor:  
   fieldValue = row.FIELD_NAME
   if row.FIELD_NAME is not None:
     arcpy.DeleteIdentical_management(FC, ["FIELD_NAME","RGNMBRCLC"])
    print "nothing left to delete"
del row, cursor

print "dedup process done"
print arcpy.GetMessages()

What I'd like to happen is for arcpy to ignore the rows where there is a NULL value in the FIELD_NAME field. Then have the delete_identical tool look through the rest of the rows and delete duplicate records. - Any ideas?

  • Which version of ArcGIS are you using? Commented Mar 5, 2015 at 20:00

2 Answers 2


Your current tool would runs "delete identical" as many times as you have a row with a value in field_name. Here is a suggested workaround to achieve what you try to do :

1) select all rows without value for the field_name

2) calculate an unique temporary value for those field (e.g. "temp_"+str(!ID!) )

3) clear selection and run the delete identical

4) set field_name values back to None


I would suggest a different method to accomplish this task. If you want to delete identicals as long as a particular field is not null, I'd create a feature layer with records where this is the case, and then perform your delete.

This would accomplish your task without a cursor:

FC = r'C:\Scripts\Drilling_Rig_Deduplication\Drilling_Rigs.gdb\MERGED_RIGS'


#Create feature layer with only records where FIELD_NAME is populated
arcpy.MakeFeatureLayer_management (FC, "lyr", sql)

#Delete identical
arcpy.DeleteIdentical_management("lyr", ["FIELD_NAME","RGNMBRCLC"])

#clean up
arcpy.Delete_management ("lyr")

I hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.