Hi everyone!
I'm using the sequential numbering script in the field calculator, and I'm trying to modify it to iterate through field values from another field so that the sequence starts over for each of the unique other values. My table looks like this -->> I'm trying to generate a Name with a Basin ID as the prefix. For now, I've been just manually selecting the basins and running the script for each one, but I'd like to be able to have the script run through them all at once:
Script I'm using:
SequentialNumber()
# Calculates a sequential number
# More calculator examples at esriurl.com/CalculatorExamples
rec=0
def SequentialNumber():
global rec
pStart = 1
pInterval = 1
if (rec == 0):
rec = pStart
else:
rec = rec + pInterval
return "WA1MH"+str(rec).zfill(4)
I'm pretty rusty on python...any help would be appreciated!
Thanks,
David Forbuss
GIS Technician
Rogue Valley Sewer Services
P O Box 3130
Central Point OR 97502
541-664-6300
Solved! Go to Solution.
@DavidForbuss1, don't worry, @JoeBorgione is going to be like Dan P. and be more active on Esri Community after he retires from his day job. 🙂
I'm glad it worked for you. For me, I much prefer to use an update cursor than the field calculator in this kind of situation.
With respect to retirement, it's in the very near future for me, so ask away!