[GIS] How to programmatically identify and rename duplicate records

arcgis-10.0python

I'm trying to identify duplicate records from a field and then change these records so they become unique (eg A,B,C, or 1,2,3) and assign this to the end of the text (eg F3241 A56_A or F3241 A56_1).
I've tried the scripts that are in this forum but can't get these to work or not sure if they will give me the result I'm after.
Any input into to this would be greatly appreciated.

Best Answer

You could use an update cursor for this:

attribs = {}
rows = arcpy.UpdateCursor (your_shapefile, "WHERE SQL", "", "FIELDS;SEPARATED;BY;SEMICOLON", "SORTFIELD A; SORTFIELD2 D")
##UpdateCursor (dataset, {where_clause}, {spatial_reference}, {fields}, {sort_fields})
for row in rows:
    if row.FIELD_OF_INTEREST in attribs:
        attribs[row.FIELD_OF_INTEREST] += 1
    else:
        attribs[row.FIELD_OF_INTEREST] = 1
    row.FIELD_OF_INTEREST = "%s_%i" % (row.FIELD_OF_INTEREST, attribs[row.FIELD_OF_INTEREST])
    rows.updateRow(row)