I am sure there is a better way of writing this, but how? import re f=file('tlst') tlst=f.read().split('\n') f.close() f=file('plst') sep=re.compile('Identifier "(.*?)"') plst=[] for elem in f.read().split('Identifier'): content='Identifier'+elem match=sep.search(content) if match: plst.append((match.group(1),content)) f.close() flst=[] for table in tlst: for prog,content in plst: if content.find(table)>0: flst.append('"%s","%s"'%(prog,table)) flst.sort() for elem in flst: print elem
What would be the best way of writing this program. BTW find>0 to check in case table=='' (empty line) so I do not include everything. tlst is of the form: tablename1 tablename2 ... plst is of the form: Identifier "Program1" Name "Random Stuff" Value "tablename2" ...other random properties Name "More Random Stuff" Identifier "Program 2" Name "Yet more stuff" Value "tablename2" ... I want to know in what programs are the tables in tlst (and only those) used. -- http://mail.python.org/mailman/listinfo/python-list