davidbrett

Find Duplicates and increment

Discussion created by davidbrett on Apr 10, 2011
Latest reply on Oct 4, 2013 by rfairhur24
Hello,

I'm attempting to find the duplicates in a field, then number the results sequentially within each duplicate set.  I've managed increment the duplicates, but not start over when the next duplicate is hit in the code.

At 9.3, I was able to use the field_Mark_Duplicates_2.cal from Easy Calculate 5.0 (http://www.ian-ko.com/free/free_arcgis.htm).  Now at 10, I need to do it in python and I'm having little success.

example of desired result:
a==>1
b==>1
c==>1
b==>2
b==>3
a==>2


Here is a snippet of code that increments all the duplicate in the table:


    rows = arcpy.UpdateCursor("Junk1.dbf")
    fields = arcpy.ListFields("Junk1.dbf" )
    
    #Create an empty list
    myList = []
       
    i = 0
    for row in rows:
        for field in fields:            
            if field.name == 'ID':
                value = row.getValue(field.name)                
                if value in myList:       
                    i += 1
                    row.TEST = i
                    rows.updateRow(row)
                if value not in myList:
                    myList.append(value)


Any help would be greatly appreciated!!

Outcomes