Re: Need Help Parsing From File

2006-12-09 Thread Markus Rosenstihl
On 2006-12-07 04:20:48 +0100, John Frame <[EMAIL PROTECTED]> said: > Hi, I've got a Python program that I'm trying to edit, and I need some help. > > If I would like to read a matrix from a previously created text file > into a two dimensional array, how would I do that? > > Like, if in the txt

Re: Need Help Parsing From File

2006-12-08 Thread Gabriel Genellina
At Friday 8/12/2006 05:30, Duncan Booth wrote: > For the Borland C++ 3.1 help (about 1991): > If "t" or "b" is not given in the string, the mode is governed by > _fmode. > If _fmode is set to O_BINARY, files are opened in binary mode. > If _fmode is set to O_TEXT, they are opened

Re: Need Help Parsing From File

2006-12-08 Thread Duncan Booth
Gabriel Genellina <[EMAIL PROTECTED]> wrote: > For the Borland C++ 3.1 help (about 1991): > If "t" or "b" is not given in the string, the mode is governed by > _fmode. > If _fmode is set to O_BINARY, files are opened in binary mode. > If _fmode is set to O_TEXT, they are opened in

Re: Need Help Parsing From File

2006-12-07 Thread Gabriel Genellina
At Friday 8/12/2006 02:23, John Machin wrote: > > > ftxt=open(filename,"rt") Why did you do that? (1) Text mode is was and ever shall be the default, even with MS. No, there used to be a flag in the stdio library, giving the default value when neither t or b was specified. For the Borland C++

Re: Need Help Parsing From File

2006-12-07 Thread Fredrik Lundh
John Machin wrote: > Indeed, and their docs say that the default for _fmode is text mode. the default doesn't matter much if you're writing library code for an application that may change it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Need Help Parsing From File

2006-12-07 Thread John Machin
On 8/12/2006 1:53 PM, Gabriel Genellina wrote: > At Thursday 7/12/2006 15:44, John Machin wrote: > >> > > > ftxt=open(filename,"rt") >> > > >> > >Is this a bug or a feature? Or is it one of those good old >> "unspecified >> > >behaviour" cases? MSVC rtl only? >> > >> > The Python docs say only th

Re: Need Help Parsing From File

2006-12-07 Thread Gabriel Genellina
At Thursday 7/12/2006 15:44, John Machin wrote: > > > ftxt=open(filename,"rt") > > > >Is this a bug or a feature? Or is it one of those good old "unspecified > >behaviour" cases? MSVC rtl only? > > The Python docs say only that the initial letter is checked. And the > ANSI 89 C says that other c

Re: Need Help Parsing From File

2006-12-07 Thread John Machin
Gabriel Genellina wrote: > At Thursday 7/12/2006 02:51, John Machin wrote: > > >Gabriel Genellina wrote: > > > > > > ftxt=open(filename,"rt") > > > >Never seen that done before. It's not in the docs. > > A remnant of my MSDOS+C background... > > >FWIW: > > > >Python 2.5 (r25:51908, Sep 19 2006, 09

Re: Need Help Parsing From File

2006-12-07 Thread Gabriel Genellina
At Thursday 7/12/2006 02:51, John Machin wrote: Gabriel Genellina wrote: > > ftxt=open(filename,"rt") Never seen that done before. It's not in the docs. A remnant of my MSDOS+C background... FWIW: Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win 32 Type "hel

Re: Need Help Parsing From File

2006-12-06 Thread John Machin
Gabriel Genellina wrote: > > ftxt=open(filename,"rt") Never seen that done before. It's not in the docs. FWIW: Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> f = open('foo.txt', 'rt')

Re: Need Help Parsing From File

2006-12-06 Thread Gabriel Genellina
At Thursday 7/12/2006 00:20, John Frame wrote: Like, if in the txt file, I had the following matrix formatted numbers with 5 rows and 10 columns, and each number is separated by a single space: 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

Re: Need Help Parsing From File

2006-12-06 Thread Soni Bergraj
John Frame wrote: > How would I read this data from the file into a two dimensional array in > Python? Like: [x.split() for x in open('myfile.txt')] Or if you need integers: [[int(a) for a in x.split()] for x in open('myfile.txt')] ;) -- Soni Bergraj http://www.YouJoy.org/ -- http://mail.pyth

Need Help Parsing From File

2006-12-06 Thread John Frame
Hi, I've got a Python program that I'm trying to edit, and I need some help. If I would like to read a matrix from a previously created text file into a two dimensional array, how would I do that? Like, if in the txt file, I had the following matrix formatted numbers with 5 rows and 10 columns