I am trying to calculate a field that marks duplicates and sequentially numbers them. I am using the code below that I found here: Generating sequential numbering for duplicate values in a field sorted by ObjectID.
It works, but I get a duplicate starting value before it begins sequentially numbering unless I only run the field calculator on the selected values. When I calculate after manually selecting the duplicate rows and running it on only those values, it works fine.
Here's the code:
prevFieldValue = ''
counter = 0
def GetDuplicateCounter(myFieldValue):
global prevFieldValue
global counter
if myFieldValue == prevFieldValue:
counter += 1
else:
counter = 1
prevFieldValue = myFieldValue
return counter
Results running it on all roads (nothing selected):
Results running it after manually selecting the duplicated fields (not too efficient!).
Best Answer
Here's how I solved the problem:
Unfortunately, I can't remember where I found the answer but if I do, I will post the credit.