Easy question
Brian Quinlan
BrianQ at ActiveState.com
Wed Apr 11 17:11:29 EDT 2001
How about something like this:
# No testing, of course
myList = []
file = open( 'testfile', 'r' )
for i in file.readlines( ):
myList.append( [int(j.strip( )) for j in i.split('\t')] )
-----Original Message-----
From: python-list-admin at python.org
[mailto:python-list-admin at python.org]On Behalf Of Duncan Smith
Sent: Wednesday, April 11, 2001 1:39 PM
To: python-list at python.org
Subject: Easy question
I need to read some data from a file. Each (tab delimited) row corresponds
to an array index eg.
0 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
...
And I need something like,
[[0,0,0,0,0,0], [0,1,0,0,0,0], [0,0,1,0,0,0], ...]
What's the best way of doing this? Cheers in advance.
Duncan Smith
--
http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list