Need Help Parsing From File

Soni Bergraj sonibergraj at youjoy.org
Wed Dec 6 22:30:06 EST 2006


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/



More information about the Python-list mailing list