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 <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN>
<SPAN class="keyword token">while</SPAN> counter <SPAN class="operator token"><</SPAN> <SPAN class="number token">11</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN>counter<SPAN class="punctuation token">)</SPAN>
counter <SPAN class="operator token">+=</SPAN> <SPAN class="number token">1</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
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<SPAN class="punctuation token">.</SPAN>CalculateField_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Streets"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"CoordSortValue"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"+=1"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"PYTHON"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
with no luck.
Is it possible to sort a table, and then calculate the position each record has in the sort?