Monday, August 1, 2011

Python/Model Builder > the first 2 weeks

Modelsample

I've??been working in both Python??and Model Builder, since my python script(s) reside in a model. I???ve been pretty impressed thus far with both ??? though I???m still right in the middle of newbie central??? I find myself digging through all the books I have, as well as the interwebs???????I've even joined the Python Users Group Mailing list in hopes of picking up on things I need help with, and to be able to ask questions when needed. (The list does get more Spam than any other list I'm apart of; maybe because it's so big?? But they really need to do something about that!)

??

At this point, my goal is simply to rewrite the VBA code into usable Python so my toolbox will run in Arc10; eventually, I???d like to rewrite the entire model in Python (less moving parts, less dependency on Arc versions ??? plus, the script can then??be executed on a virtual server).

??

At the end of our python class, I had a major complaint that we shouldn???t have used the last afternoon going over python that wasn???t directly related to Arc ??? well, last week I found out why she had the class set up that way???.

??

When it comes down to using python to pound through your data/tables, Regular Expressions are inevitably necessary??? I have been backward and forward through that section of the book, and now hope that I can find a class that picks up with Python where that class left off. While I???m using python in my model, at present I???m using a Field Calculator with python code, which is awesome because I don???t have to worry about setting up a loop to run through each row ??? just an FYI??? There are some limitations of doing it that way, but for the record, you CAN import modules while in Field Calculator ??? tested this last week. I???m down to the knitty-gritty in the first implementation of code, but I???m stuck on one issue ??? the ???DEPTH_FROM??? field in the Property_Tract_Status table, in some instances, has words (which I???m successfully parsing through) and in others there are numbers.

??

You???d think the rows with numbers would be easy to deal with numbers, right? Well, there???s a huge catch??? The numbers have commas as thousand???s separators??? effectively creating what???s known as a ???tuple??? in python.

??

My hope is that I can use the split function and then strip the comma, then recompile into a number and then proceed through the rest of my code ??? I started this on Friday, but so far have been unsuccessful?????

??

I found an IDE that I think far superior to PythonWin?? and IDLE > it???s called PyScripter (http://code.google.com/p/pyscripter/) < it???s freeware, and it works like a champ ?????it lets you navigate through the functions, objects, and imported modules. I'm now using it exclusively;??although, I usually have all three IDEs open (PyScripter, PythonWin, & IDLE), since using IDLE for ???help()??? is the fastest/easiest way to get said help (on things/functions of python outside of ArcPy)???

No comments:

Post a Comment