I have a table that has one field with duplicate values. Is there any code that will label the duplicates 0, 1, 2, 3, 4 ..., rather than 0 and 1 as the following code does which I've found on ESRI's web site.
Python parser, and use then use the following codebook.
uniqueList = []
def isDuplicate(inValue):
if inValue in uniqueList:
return 1
else:
uniqueList.append(inValue)
return 0
isDuplicate(!PCN!)
Solved! Go to Solution.
uniqueList={}
def isDuplicate(inValue):
global uniqueList
if inValue in uniqueList.keys():
uniqueList[inValue] += 1
return uniqueList[inValue]
else:
uniqueList[inValue] = 0
return uniqueList[inValue]
Using the Python Parser, insert the following into the code block.
This will perform the same operation as the above, but will increment the duplicate records as 0, 1, 2, 3 ... and then revert to 0 when it hits the next unique value.
At the end you would then use the isDuplicate(!<Your Field Name>!)
I am not sure I understand. You are saying that you have a field that has values like 1,2,2,3,4,4,5 etc. and you want 1,2,3,4,5,6 what is the value of this. Why not just use the OID if you need a UID (unique identifier). If this will not work- what you want can be done with python using an UpdateCursor: here is info on it.
then just update the row with a count variable. and increment it each time though the loop. count += 1 i.e. count = count + 1
uniqueList={}
def isDuplicate(inValue):
global uniqueList
if inValue in uniqueList.keys():
uniqueList[inValue] += 1
return uniqueList[inValue]
else:
uniqueList[inValue] = 0
return uniqueList[inValue]
Using the Python Parser, insert the following into the code block.
This will perform the same operation as the above, but will increment the duplicate records as 0, 1, 2, 3 ... and then revert to 0 when it hits the next unique value.
At the end you would then use the isDuplicate(!<Your Field Name>!)
Brian, thank you so much, it worked perfectly.
this thread still remains open, if a solution was provided please select the correct answer to finalize the discussion