-2

I need Python code for deleting all identical values which are compared within one column.

Column where the identicals should be located and deleted

As you can see in the image there are many identical values which I want to get rid of. I tried the delete identical tool but it won´t work in my situation. It could be that I just used it wrong but as I thought the tool only compares values between columns and not within one row.

Does anybody have a solution for me? Python or Toolbox-Tool? The identical rows and features should be deleted and one of them should be kept.

  • 2
    Welcome to GIS SE. As a new user, please take the Tour. Coding questions here are expected to contain a good-faith effort toward solving the task, with a complete description of the error encountered. "I need code" requests are likely to be ignored (or down-voted/close-voted, then ignored). Please Edit the question to specify what you have tried and what problem you encountered. – Vince Jun 10 at 17:16
  • I don't think "off-topic" was a fair reason to close this question. Maybe it needs details, but I don't agree that it should have been closed. – Pdavis327 Jun 11 at 18:58
1

You could use a search cursor and list to check for and delete duplicates.

import arcpy

fc = r'path'

addr = []
with arcpy.da.UpdateCursor(fc, "ADRESSE") as cursor:
    for row in cursor:
        if not row[0] in addr:
            addr.append(row[0])
        else:
            cursor.deleteRow()
| improve this answer | |
  • Thank you! I´ll give it a shot and let you know if it worked :-) – Chris Jun 10 at 17:29

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