python beginner needs instant help calculating field

5021
21
Jump to solution
12-02-2015 01:04 PM
AMiller
New Contributor III

Hi, I haven't yet learned how to use python, I know a tiny bit. I am using ArcMAp 10.2. I want to use a python program to Calculate a filed as a sequential ID, as I found instructions for in "Help" under calculate field examples (Accumulative and sequential calculations).

I am at a loss as to how to enter the info properly in the calculate field dialogue boxes. I have tried a few times, not at all sure where my basic problem lies. I need to do this real fast, but I just get lost or nowhere. Can you give my python future a quick boost? What do I type in the code block? what do I type in the other area? how do I have to alter the code for my scenario (from as it is typed in the help example?)

What type of field can I use for my new ID? I created a text field, is that ok?

0 Kudos
1 Solution

Accepted Solutions
JoeBorgione
MVP Emeritus

Do exactly what it says here and you'll be good to go.  I just tried it:

38517 - Create sequential numbers in a field using Python in the Field Calculator

It looks something like this:

I just added a long int field named MyField to test.....

That should just about do it....

View solution in original post

21 Replies
DanPatterson_Retired
MVP Emeritus

I only have time for one question given your rush, this will at least get you started...  integers should go in a numeric field with no decimal places

AMiller
New Contributor III

Thanks, will you have any time in near future? I may get to talk to ESRI tech support today, not sure. Thanks for clarifying the field requirement. I wanted to use text in my ID field, as I didn’t want the field to ever be calculated by mistake, but I suppose converting it to text might be another step.

0 Kudos
JoeBorgione
MVP Emeritus

Do exactly what it says here and you'll be good to go.  I just tried it:

38517 - Create sequential numbers in a field using Python in the Field Calculator

It looks something like this:

I just added a long int field named MyField to test.....

That should just about do it....
AMiller
New Contributor III

Thank you so much, I am about to try…

Adrienne

0 Kudos
AMiller
New Contributor III

I tried and still not working, I tried a short integer field , and a long integer field. I tried with all records unselected, and I tried with all records selected.

0 Kudos
DanPatterson_Retired
MVP Emeritus

and you made the field active by clicking on its title, prior to doing the field calculation... and you do have the code block specified?

0 Kudos
DarrenWiens2
MVP Honored Contributor

What does the error (if any) in the Results window tell you was the problem?

0 Kudos
AMiller
New Contributor III

Hi Darren, I did resolve my issue, with ESRI tech support. The problem I encountered at first (with instructions sent by Joe B) seemed to be resolved by trying the process in a new document. Thanks for your attention, appreciate it.

0 Kudos
ChrisDonohue__GISP
MVP Alum

To elaborate upon the suggestion by Darren Wiens ,here's how you check the Results for errors or other informational messages:

geoprocessing_results_pulldown.jpg

Here's the Results windows that comes up.  Click on the plus signs to expand.  Drill down to the specific run you did and then expand the Messages.  If there is an error, there will be red x's.  Oftentimes the Error message will have a link to further explain the error (though admittedly some links just say you got a generic error, which isn't much help).

geoprocessing_results_pulldown_Window.jpg

Chris Donohue, GISP