1

I want to know if anyone has a code to count +1 starting at a certain number for Field Calc. ArcGIS. (I.e. 04312, 04313) It also must keep the 0 in front.

rec=0
def autoIncrement():
 global rec
 pStart = 040150117669
 pInterval = 1
 if (rec == 0): 
  rec = pStart 
 else: 
  rec = rec + pInterval 
 return rec

    str(autoIncrement( )).zfill(12)

parsing error syntaxerror:invalid token (line 4)

1 Answers1

1

Use block

rec=0
def autoIncrement():
 global rec
 pStart = 1 #adjust start value, if req'd 
 pInterval = 1 #adjust interval value, if req'd
 if (rec == 0): 
  rec = pStart 
 else: 
  rec = rec + pInterval 
 return rec

Call it using:

str(autoIncrement( )).zfill(5)

It will work on text field

FelixIP
  • 22,922
  • 3
  • 29
  • 61