0

I have total 96 records which are having duplicate values like 999999.

What i want is to convert these values into unique ones like 999901,999902,999903 and so on, through the 96 records.

I want only 2 digits to be replaced as rowids but there may also be cases where i have to change three digits too.

2
  • Not sure I quite understand the last part (2 digits vs. 3 digits?) but would you be able to just Field Calculate the field to "9999"+str(!OBJECTID!).zfill(2) if your OBJECTID or FID already increments from 1-96?
    – John
    Sep 16, 2015 at 12:31
  • I wanted to mention that i dont want to change the length of the digits , i just want to change the numbers . as i have 96 duplicates of 999999 and i want to remove them. for three digits i wanted to know that if i will have 200 duplicates of the 999999 , than i will have to start it by 999001,999002 like this . Sep 17, 2015 at 5:11

1 Answer 1

1

Borrowing from the Calculate Field Examples in the ESRI Help Docs about incrementing calculations, here is a Field Calculator example that works for a user-defined number of padding.

Important! You need to change the pPad variable to the number of digits you want to right-pad (e.g. 2 or 3). This will maintain 6 total digits no matter how many values you pad.

Code Block

rec=0
def autoIncrement():
    global rec
    pStart = 1 #adjust start value, if req'd 
    pInterval = 1 #adjust interval value, if req'd
    pPad = 2 #adjust right-padded value, if req'd
    if (rec == 0): 
        rec = pStart 
    else: 
        rec = rec + pInterval 
    return "999999"[:-pPad] + str(rec).zfill(pPad)

Expression Line

autoIncrement()

Parser

Python

Field Calculator

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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