Select to view content in your preferred language

Trying to write a python script to access data from attribute tables

4701
23
Jump to solution
07-22-2014 09:28 AM
ThomasCaruso
Deactivated User

Hi folks. I'm new to both GIS and programming and am attempting to combine the two. I need a python script that will read down a particular column of the attribute table of a particular layer, then check it against a column in the attribute table of another layer. Both of these columns will contain strings. If the two match, then the script should input "YES" into another field in the first layer.

I honestly have no idea how to even start this. I've read through esri's help section and have a very basic grasp of python but I'm unsure of how to get the script to actually access the attribute tables. Any help would be very greatly appreciated.

Thanks in advance! If there's a better place to post this, please let me know.

Tags (2)
23 Replies
DanPatterson_Retired
MVP Emeritus

Not bad for a first crack!!!  See Ian's example below

0 Kudos
ThomasCaruso
Deactivated User

Thanks for the kind words! I'll only get better with more practice and experience. Thanks again for your help!

0 Kudos
DanielAmrine
Frequent Contributor

Thomas,

Did this code work as you planned it?

If so did you incorporate it as a script tool in a model, use field calculator, run it using the "Python" window in ArcMap, or as a standalone python script?

I've been trying to learn scripting as well but I am confused on the best place to incorporate it into the working MXD.

Thanks!,

Dan Amrine

0 Kudos
ThomasCaruso
Deactivated User

Hi Dan,

I've been doing everything in the python window. Unfortunately I have only a basic version of ArcGIS so I don't believe I have the capability to add models, although I might get an upgraded version once I show I have the abilities to actually use it.

I'm still trying to get it to work properly, but I'm close. The help I've recieved here has been absolutely invaluable.

Hope this helps!

Note: I've been using the method that was recommended to me by Ian above, while I'm going to try to get my code to work properly I've realized that my methodology was not the best way to go about handling the problem.

0 Kudos