10.1 code that populates a field with sequential numbers

464
2
Jump to solution
09-18-2013 01:43 PM
ShikoNjuno
Occasional Contributor
Hi folks,
I have a shapefile whose ID and FID numbers are all messed up in the attribute table and I'm looking for code I can type into my "Field Calculator" window that will fill in unique values for each polygon.
Any samples anyone?!!?! 🙂
Thanks

Here's what I've tried so far:

[ATTACH=CONFIG]27562[/ATTACH]

The complete code is:

rec=0
def autoIncrement():
global rec
pStart = 1 #adjust start value, if req'd
pInterval = 1 #adjust interval value, if req'd
if (rec == 0):
  rec = pStart
else:
  rec = rec + pInterval
return rec


Anyone see any issues that might be causing this not to work?
The error msg I keep getting is the dreaded 99999 error. :confused:
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
You just need to make the expression with the parenthesis to execute the function.

autoIncrement()

View solution in original post

0 Kudos
2 Replies
by Anonymous User
Not applicable
You just need to make the expression with the parenthesis to execute the function.

autoIncrement()
0 Kudos
ShikoNjuno
Occasional Contributor
You just need to make the expression with the parenthesis to execute the function.

autoIncrement()


Yaaay.....little mistake.....huge difference!!!!
Thank you sooo much 😄
Cheers
0 Kudos