Re: read file into list of lists

2008-07-11 Thread Paddy
On Jul 11, 9:32 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jul 11, 11:35 pm, Paddy <[EMAIL PROTECTED]> wrote: > > > > > On Jul 11, 2:15 pm, antar2 <[EMAIL PROTECTED]> wrote: > > > > Hello, > > > > I can not find out how to read a file into a list of lists. I know how > > > to split a text into

Re: read file into list of lists

2008-07-11 Thread John Machin
On Jul 11, 11:35 pm, Paddy <[EMAIL PROTECTED]> wrote: > On Jul 11, 2:15 pm, antar2 <[EMAIL PROTECTED]> wrote: > > > > > Hello, > > > I can not find out how to read a file into a list of lists. I know how > > to split a text into a list > > > sentences = line.split(\n) > > > following text for examp

Re: read file into list of lists

2008-07-11 Thread Jeffrey Froman
Laurent Rahuel wrote that antar2 wrote: >> following text for example should be considered as a list of lists (3 >> columns and 3 rows), so that when I make the print statement list[0] >> [0], that the word pear appears >> >> >> pear noun singular >> books nouns plural >> table noun singular Fi

Re: read file into list of lists

2008-07-11 Thread Gerard flanagan
antar2 wrote: Hello, I can not find out how to read a file into a list of lists. I know how to split a text into a list sentences = line.split(\n) following text for example should be considered as a list of lists (3 columns and 3 rows), so that when I make the print statement list[0] [0], tha

Re: read file into list of lists

2008-07-11 Thread Paddy
On Jul 11, 2:15 pm, antar2 <[EMAIL PROTECTED]> wrote: > Hello, > > I can not find out how to read a file into a list of lists. I know how > to split a text into a list > > sentences = line.split(\n) > > following text for example should be considered as a list of lists (3 > columns and 3 rows), so

Re: read file into list of lists

2008-07-11 Thread bockman
On 11 Lug, 15:15, antar2 <[EMAIL PROTECTED]> wrote: > Hello, > > I can not find out how to read a file into a list of lists. I know how > to split a text into a list > > sentences = line.split(\n) > > following text for example should be considered as a list of lists (3 > columns and 3 rows), so th

Re: read file into list of lists

2008-07-11 Thread Laurent Rahuel
Hello, A way to do it === from __future__ import with_statement res = [] with open("sentences.txt","r") as f: sentences = [elem for elem in f.read().split('\n') if elem] for sentence in sentences: res.append(sentence.split()) p

read file into list of lists

2008-07-11 Thread antar2
Hello, I can not find out how to read a file into a list of lists. I know how to split a text into a list sentences = line.split(\n) following text for example should be considered as a list of lists (3 columns and 3 rows), so that when I make the print statement list[0] [0], that the word pear