I am searching for a way to auto increment an ArcGIS field which begins with text and followed by numbers. Ex. SWCL0000. I have tried the auto increment code in the field calculator but once I added text and a starting number, I kept on getting errors.
I borrowed a lot of the code from here. Try this.
Turn on the
python parser in the Field Calculator.
Pre-Logic Script Code:
rec = 0 def autoInc(): global rec pStart = 1 pInterval = 1 if (rec == 0): rec = pStart else: rec += pInterval return rec
"SWCL" + str(autoInc()).zfill(4)
.zfill() function makes sure your string is at least n characters long and will pad with zeroes.