Need Help Parsing From File

John Frame jframe at vt.edu
Wed Dec 6 22:20:48 EST 2006


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?



More information about the Python-list mailing list