Compare 2 files and discard common lines

BJörn Lindqvist bjourne at gmail.com
Thu May 29 17:08:28 EDT 2008


Open('3rd', 'w').writelines(set(open('2nd').readlines())-set(open('1st')))

2008/5/29, loial <jldunn2000 at googlemail.com>:
> 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?
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
mvh Björn



More information about the Python-list mailing list