oops i forgot to count lines,

MainDictionary = {}
N = 0
M = 0
for line in open('data_file', 'r'):
    if line:
        if M < 3:
            N += 1
            M += 1
            a, b = line.split(" = ")  # "=" is in between spaces whish gives
you only two variables.
            if a == 'Field':
                MainDictionary[N] == {}
            elif a == 'Index':
                MainDictionary[N]['Value'] = {b}
        else:
            a, b = line.split(" = ")  # "=" is in between spaces whish gives
you only two variables.
            if a == 'Field':
                MainDictionary[N] == {}
            elif a == 'Index':
                MainDictionary[N]['Value'] = {b}
             M = 0
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to