I am new to python programming. I am wondering if someone could tell me how to write a python script that would find all records in an attribute table that have identical values in one field, then from this subset find the records that are identical based on a second field, then from this subset of records delete record(s) based on conditions set for a third field. So for example, if five records have the same values in field "C", and two of these records have the same values in field "A", but have different values in field "B", I want to delete just one of these records, specifically the one that has a "null" value in field "B".

The attribute table has ~5000 records, I need to delete about ~400 of these records b/c they are identical to other records in this table.

In the example shown below, I would want to use Python to find the records with identical values in "FEAT_SEQ*" field, then from this subset find records with identical values in the "SHAPE_len" field, then from this subset delete the record with a "Null" value in the "edited" field. In this example, I would keep three records, and delete the record that is second from the top ("IN_FID*" = 23)

enter image description here

I am working in ArcGIS 10.1


This can be done without Python in a few step, and you can use arcpy to put those steps together if needed.

1) Concatenate FEAT_SEQ and SHAPE_Len in a new text field (!FEAT_SEQ! + str(SHAPE_Len)

2) Then use summary statistics based on the concatenated field

3) you will have a table with the number of duplicates. Select all row where the count is equal to one and delete them

4) join the table to your original table (keep only matching records)

5) select the features with a null value, and delete them in an edit session.

as a remark, the first step could be simplified with the advanced licence, using the find identical tool with FEAT_SEQ and SHAPE_Len to create a table of identical features.

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