Compare 2 files and discard common lines

Paul McGuire ptmcg at austin.rr.com
Tue Jun 3 01:37:42 EDT 2008


On May 29, 3:36 am, loial <jldunn2... at googlemail.com> 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?

Take the time to learn difflib - it is a standard module, and good for
general comparison of files, sequences, etc.

-- Paul



More information about the Python-list mailing list