[Tutor] manipulating data

Bryan Fodness bryan.fodness at gmail.com
Mon Nov 12 20:43:19 CET 2007


I try this,

f = open('TEST1.MLC')

fields = {}

for line in f:
    if line.split()[0] == 'Field':
        field = int(line.split()[-1])
    elif line.split()[0] == 'Leaf':
        fields[field] = line.split()[-1]
    else:
        line = f.next()

and get,

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    line.split()[0]
IndexError: list index out of range

I have attached my data file.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: TEST1.MLC
Url: http://mail.python.org/pipermail/tutor/attachments/20071112/70da63cf/attachment.txt 


More information about the Tutor mailing list