Whoops! Had to correct it!

Hey, I had a similar problem not too long ago. My data came in the first
format, but I didn't need it formated like that.

Here is how I would have written it:

import re
col=re.compile('(AD.*?)\s*$')
datas=re.compile('\s*(.+?)\s+(.+?)')
f1 = open('xx','r')
mind={}
matching=''

for i in fl:
        match=col.find(i)
        if match:
                mind[match.group(1)]=[]
                matching=match.group(1)
        match=datas.find(i)
        if match:
                mind[matching].append([match.group(1),match.group(2)])


That would collect the data and put it into a dictionary with the values
being a list of the two part data. You could print like this:

for each in mind.keys():
        print each
        for value in mind[each]:
                print each+"    "+value[0]+"    "+value[1]


That should do it!

Ask if you don't understand any part of it.

Allen J. Schmidt, Jr.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to