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

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()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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