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

Re: Pulling numbers from ASCII filename not working

2006-01-26 Thread Dave Hansen
On Thu, 26 Jan 2006 06:39:20 GMT in comp.lang.python, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On 25 Jan 2006 12:42:20 -0800, IamIan [EMAIL PROTECTED] declaimed the following in comp.lang.python: [...] I tried print repr(filename) and it returned the actual filename: 'n16w099.asc' ,

Re: Pulling numbers from ASCII filename not working

2006-01-26 Thread Bengt Richter
On 25 Jan 2006 12:42:20 -0800, IamIan [EMAIL PROTECTED] wrote: 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

Re: Pulling numbers from ASCII filename not working

2006-01-25 Thread Bengt Richter
On 24 Jan 2006 10:44:32 -0800, IamIan [EMAIL PROTECTED] wrote: 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

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 =

Re: Pulling numbers from ASCII filename not working

2006-01-25 Thread Steven D'Aprano
On Wed, 25 Jan 2006 12:42:20 -0800, IamIan wrote: 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

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. --

Re: Pulling numbers from ASCII filename not working

2006-01-25 Thread Steven D'Aprano
On Wed, 25 Jan 2006 16:57:47 -0800, IamIan wrote: 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

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

Re: Pulling numbers from ASCII filename not working

2006-01-24 Thread mrmakent
First: http://www.catb.org/~esr/faqs/smart-questions.html You say your program 'crashes' when it gets to 'int(LatString)'. I'm guessing (and it's entirely a guess, since you don't tell us) that you are getting an exception like 'ValueError: invalid literal for int(): whatever'. I'm guessing

Re: Pulling numbers from ASCII filename not working

2006-01-24 Thread Larry Bates
At lest one of the filenames (or directories) being returned by os.listdir doesn't have integer value where you are looking. Remember that os.listdir returns subdirectories as well as files. You may want to look at using glob.glob() instead and limit it to *.asc. Secondly, filenames =

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-24 Thread Fredrik Lundh
IamIan [EMAIL PROTECTED] wrote: The exception I get is TypeError: Cannot add value 'int' to string. now that you've posted the exception, can you please post the code you're using, and the *complete* traceback. (the stuff you posted earlier contained syntax errors, and didn't con- tain any