How can I compare if 2 files has duplicate entries in python?

Larry Bates larry.bates at websafe.com
Tue Mar 21 11:49:50 EST 2006


yinglcs at gmail.com wrote:
> I am new to python. How can I compare if 2 files has duplicate entries
> in python?
> Is there an example for that?  What if the files are big and I don't
> want to read the whole file in memory.
> 
> Thank you.
> 

You need to supply more info.  If you just want to determine if two
files are exactly alike you can just calculate the md5 checksum or
each file.  If they are different, the files are different.  See:

http://docs.python.org/lib/module-md5.html


If you want to compare files line by line see following:

http://docs.python.org/lib/module-difflib.html


-Larry Bates



More information about the Python-list mailing list