Re: [Tutor] File IO Help again

2005-10-28 Thread Liam Clarke
Heh, Cut 'im some slack there Bob, I only just figured out that line[:1] == line[0]... On 10/28/05, bob <[EMAIL PROTECTED]> wrote: > At 01:42 PM 10/27/2005, Adam wrote: > > >if line[:1] == "1": > > > >This line won't work because you're getting the first 2 characters from > >the line > > Oh? Did

Re: [Tutor] File IO help

2005-10-28 Thread Liam Clarke
Oops, filePaths = [os.path.join(direc, item) for item in os.listdir(direc) if not os.path.isdir(os.path.join(direc, item))] should be > filePaths = [os.path.join(dirPath, item) for item in os.listdir(dirPath) > if not os.path.isdir(os.path.join(dirPath, item))] ... __

Re: [Tutor] File IO help

2005-10-28 Thread Kent Johnson
Mike Haft wrote: > Hello all, > I'm new to python but so far I have to say its a really good language > > I've been having some trouble with File IO can anyone help? I've got the > basics but my problem is that I have many files (one for each year of the > last 100 years or so) that look l

Re: [Tutor] File IO Help again

2005-10-27 Thread bob
At 01:42 PM 10/27/2005, Adam wrote: > >if line[:1] == "1": > >This line won't work because you're getting the first 2 characters from >the line Oh? Did you test that? When I do that I get 1 character. Why? Because slicing goes UP TO the 2nd argument. >>> 'abc'[:1] 'a'

Re: [Tutor] File IO Help again

2005-10-27 Thread Adam
>if line[:1] == "1": This line won't work because you're getting the first 2 characters from the line and seeing if it's equal to a string of length one. For example in your test file if you put this line, 1      12.4    12.0    *   10 , through that bit of code it would see if "1 " == "1", which

Re: [Tutor] File IO Help again

2005-10-27 Thread bob
At 12:18 PM 10/27/2005, Mike Haft wrote: >Apologies for not making things clearer last time. > >My specific problems are: > >why can I not get the readline() or readlines() functions to work, I'm >told they are not defined whenever I try. Mike * Oh * Mike ... and all others ... Please Post The Co

Re: [Tutor] File IO Help again

2005-10-27 Thread Danny Yoo
On Thu, 27 Oct 2005, Mike Haft wrote: > why can I not get the readline() or readlines() functions to work, I'm > told they are not defined whenever I try. Don't paraphrase. *grin* Show us what you did in terms of the code that you ran. Also, include the literal error message and its tracebac

[Tutor] File IO Help again

2005-10-27 Thread Mike Haft
Apologies for not making things clearer last time. My specific problems are: why can I not get the readline() or readlines() functions to work, I'm told they are not defined whenever I try. Also the following: if line[:1] == "1": collects data from month 1, 10, 11, and 12. How do I make the re

[Tutor] File IO help

2005-10-26 Thread Mike Haft
Hello all, I'm new to python but so far I have to say its a really good language I've been having some trouble with File IO can anyone help? I've got the basics but my problem is that I have many files (one for each year of the last 100 years or so) that look like this: MONTH RAIN AVTE