Pulling numbers from ASCII filename not working

2006-01-24 Thread IamIan
I searched the archives but couldn't find anyone else with this problem. Basically I'm grabbing all ASCII files in a directory and doing geoprocessing on them. I need to calculate a z-factor based on the latitude of the ASCII file being worked on, which is in the filename. If I type in the code man

Re: Pulling numbers from ASCII filename not working

2006-01-24 Thread IamIan
The exception I get is "TypeError: Cannot add value 'int' to string." I have looked at LatString, and it is the string representation of latitude ('17' etc.). What's odd is that the exception is raised not when I include LatInt = int(LatString), but when I try to print LatInt's value or multiply it

Re: Pulling numbers from ASCII filename not working

2006-01-25 Thread IamIan
Thank you for the replies, I'm new to Python and appreciate your patience. I'm using Python 2.1. To reiterate, the ASCII files in the workspace are being read correctly and their latitude values (coming from the filenames) are successfully being converted to string. Even doing LatInt = int(LatStri

Re: Pulling numbers from ASCII filename not working

2006-01-25 Thread IamIan
>Dude. You're trying to add a string to an int. What did you think would >happen? Dude. I thought it would concatenate the value for LatInt with the rest of the sentence; I wasn't literally trying to add them. Apparently you can only concatenate strings like this in Python. -- http://mail.python

Re: Pulling numbers from ASCII filename not working

2006-02-01 Thread IamIan
Thanks for the help everyone (especially those that gave more answers than attitude). It's working perfectly! Ian -- http://mail.python.org/mailman/listinfo/python-list

Help with os.spawnv

2006-02-09 Thread IamIan
I've had to migrate back to Python 2.1 and am now trying to use os.spawnv to get around a memory leak (either in Python or ArcGIS or both) in a geoprocessing script. This script (Second Script) gets each Ascii file in the workspace, converts it to a raster, sets the spatial reference, and hillshad

Exiting os.spawnv's subroutine

2006-02-17 Thread IamIan
I am using os.spawnv in Python 2.1 to do some geoprocessing in a subroutine/process. Everything works great, except when the processing is done the subroutine just waits for a couple minutes before closing itself and returning to the main script. I have tried using sys.exit() and exit() but these a

Re: Exiting os.spawnv's subroutine

2006-02-21 Thread IamIan
My code is below. As a single script there is no pause at the end of the processing as there is with using os.spawnv... I am using the P_WAIT value, and wonder if it is responsible for the extra time at the end of each iteration. Could it take longer for the processing to be "successful" when run u

Re: Exiting os.spawnv's subroutine

2006-02-22 Thread IamIan
Strange but removing the try/except part of the second script (leaving only the processing) removed the 2 minute lag at the end of each subroutine. -- http://mail.python.org/mailman/listinfo/python-list

08 and 09 in sequence create "invalid token" error?!

2007-04-06 Thread IamIan
Hello all, I am confused as to why including 08 or 09 in a sequence (list or tuple) causes this error. All other numbers with a leading zero work. [01,02,03,04,05,06,07] is fine [01,02,03,04,05,06,07,10] is fine [01,02,03,04,05,06,08] produces "SyntaxError: invalid token", as does: [01,02,03,

Re: 08 and 09 in sequence create "invalid token" error?!

2007-04-06 Thread IamIan
Thank you! Ian -- http://mail.python.org/mailman/listinfo/python-list

Nested dictionaries trouble

2007-04-11 Thread IamIan
Hello, I'm writing a simple FTP log parser that sums file sizes as it runs. I have a yearTotals dictionary with year keys and the monthTotals dictionary as its values. The monthTotals dictionary has month keys and file size values. The script works except the results are written for all years, rat

Re: Nested dictionaries trouble

2007-04-11 Thread IamIan
Thank you everyone for the helpful replies. Some of the solutions were new to me, but the script now runs successfully. I'm still learning to ride the snake but I love this language! Ian -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested dictionaries trouble

2007-04-18 Thread IamIan
I am using the suggested approach to make a years list: years = ["199%s" % x for x in range(0,10)] years += ["200%s" % x for x in range(0,10)] I haven't had any luck doing this in one line though. Is it possible? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested dictionaries trouble

2007-04-19 Thread IamIan
Thank you again for the great suggestions. I have one final question about creating a httpMonths dictionary like {'Jan':'01' , 'Feb':'02' , etc} with a minimal amount of typing. My code follows (using Python 2.3.4): import calendar # Create years list, formatting as strings years = map(str, xrang

Regexp not performing the same in FTP versus Python

2007-02-08 Thread IamIan
Hello all, I'm trying to use a regular expression in an FTP script to list certain files. When run in a standard FTP session the command: dir .??[oOdDnNmM]* returns 48 files. When I use the following Python script it prints roughly 12 files (a subset of the 48), ending with 'None': imp

Re: Regexp not performing the same in FTP versus Python

2007-02-08 Thread IamIan
It's strange but since more files have been added to this directory the regexp appears to be working correctly. Sorry to bother the list and thanks for your time. Ian -- http://mail.python.org/mailman/listinfo/python-list