1

How do I auto increment every second row (field type is short and I work with 150 fields) in ArcGIS Desktop 10.3.1?

I saw this code in https://support.esri.com/en/technical-article/000011137

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

 autoIncrement()

and the unwanted result is the blue arrow, whereas i need the result will be the as the yellow arrow (i changed it manually):

enter image description here

1 Answer 1

2

Not tested, but this should work:

rec=0 
action = 'jump'
def autoIncrement(): 
 global rec
 global action  
 pStart = 1  
 pInterval = 1 
 if (rec == 0):  
  rec = pStart
  return rec
 else:
  if action == 'count':
   rec += pInterval
   action = 'jump'
   return rec
  elif action == 'jump':  
   action = 'count'
   return 0

 autoIncrement()
0

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.