On May 29, 3:36 pm, loial <[EMAIL PROTECTED]> wrote: > I have a requirement to compare 2 text files and write to a 3rd file > only those lines that appear in the 2nd file but not in the 1st file. > > Rather than re-invent the wheel I am wondering if anyone has written > anything already?
It's so easy to do that it won't count as reinventing the wheel: a = open('a.txt', 'r').read().split('\n') b = open('b.txt', 'r').read().split('\n') c = open('c.txt', 'w') c.write('\n'.join([comm for comm in b if not (comm in a)])) c.close() it's not the fastest common searcher but it works. -- http://mail.python.org/mailman/listinfo/python-list