AnsweredAssumed Answered

Increment Field in Sorted Table

Question asked by jborgion on Oct 30, 2017
Latest reply on Nov 1, 2017 by jborgion

I've seen a few posts here and on stack exchange that mention this topic, but when I use the code provided it fails. This seems pretty straight forward:

 

counter = 1
while counter < 11:
  print (counter)
  counter += 1

 and when in an idle window, returns :

1

2

3

....

10 

 As expected.  However, if I put something like that in the field calculator, I get 000539 Error.  It seems that any auto-incrementer I've found online has a dependency on the OID in way or another.  I've tried a da.UpdateCursor, and CalculateField_managment:  

arcpy.CalculateField_management("Streets","CoordSortValue","+=1","PYTHON")

with no luck.

 

Is it possible to sort a table, and then calculate the position each record has in the sort?

Outcomes