python beginner needs instant help calculating field

4984
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
21 Replies
AMiller
New Contributor III

Yes, thank you.

0 Kudos
AMiller
New Contributor III

Thanks everyone, I was just on phone with ESRI tech support, I was having some kind of issue with my existing document, the directions sent by Joe Borgione worked when I (we) tried doing in a new document.

Problem solved!! Yay!! ☺

0 Kudos
ChrisSmith7
Frequent Contributor

If you're having trouble auto-incrementing using Python, you can easily field calculate the FID or ObjectID field into your named ID field... if you need it to start at 1, just add 1 to your result, e.g. [FID] + 1

DarrenWiens2
MVP Honored Contributor

Of course, provided no FIDs are missing.

AMiller
New Contributor III

Thanks everyone, I was just on phone with ESRI tech support, I was having some kind of issue with my existing document, the directions sent by Joe Borgione worked when I (we) tried doing in a new document.

Problem solved!! Yay!! ☺

0 Kudos
ChrisSmith7
Frequent Contributor

Should be ok if they are calculating a shapefile field - as I understand, these are renumbered from 0 - no gaps will show-up. Of course, not the same for geodatabase!

AMiller
New Contributor III

Thanks everyone, I was just on phone with ESRI tech support, I was having some kind of issue with my existing document, the directions sent by Joe Borgione worked when I (we) tried doing in a new document.

Problem solved!! Yay!! ☺

0 Kudos
AMiller
New Contributor III

Thanks everyone, I was just on phone with ESRI tech support, I was having some kind of issue with my existing document, the directions sent by Joe Borgione worked when I (we) tried doing in a new document.

Problem solved!! Yay!! ☺

0 Kudos
DavidAllen
Occasional Contributor

Here's a little inside info that can benefit everyone wanting to do calculations in the field calculator using Python. The book "GIS Tutorial for Python Scripting" has a chapter on this ... AND YOU CAN GET THAT CHAPTER FOR FREE!

Go to this Esri Press site and click "Sample Chapter":

Esri Press | GIS Tutorial for Python Scripting

You can get the data necessary to do all the work for this book at this site and click under "Resources":

Esri Press Book Resources | GIS Tutorial for Python® Scripting

That'll get you started with Python - then you can buy the rest of the book later. By the time you finish all those tutorials and exercises you should be asking for a raise!

David W. Allen

KathleenWallis
Occasional Contributor II

Although this document is a little dated, keep it in your files. You will find that you refer to it often.
Katy