Need Help Parsing From File
Markus Rosenstihl
mrosenstihl at macnews.de
Sat Dec 9 19:23:44 EST 2006
On 2006-12-07 04:20:48 +0100, John Frame <jframe at vt.edu> 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 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 45 46 47 48 49 50
> 51 52 53 54 55 56 57 58 59 60
>
> How would I read this data from the file into a two dimensional array
> in Python?
In case you have imported pylab:
myarray = pylab.load('textfile.txt')
Regards
Markus
More information about the Python-list
mailing list