-1

Subsequent to Auto incrementing every second row in ArcGIS Desktop? , how can i start the auto increment from the second field (i work with 150 fields)

enter image description here

so the result will be:

enter image description here

closed as off-topic by PolyGeo May 27 at 20:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

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

 autoIncrement()
  • 3
    If you used a modulus math function this function would be significantly faster than the current string comparison. – Vince May 27 at 11:53
  • @Vince Absolutely! I was just trying to build upon the original snippet provided in the OP's first question. – umbe1987 May 27 at 12:33

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