basic comparing files
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Thu May 15 19:18:11 EDT 2008
En Thu, 15 May 2008 06:02:29 -0300, Beema shafreen
<beema.shafreen at gmail.com> escribió:
> I am comparing two files A and B
> which has three columns a1, b1 of A and a2, b2
*three* columns? You menction only two of them.
> say for example if need to compare a1 with a2 and if there are common i
> have
> display a1, b1, b2
> or else i have to display a1 , b1 or a1, b2
Do you have to syncrhonize both listings? That is, search for matches that
are not in the same line? Or just compare line by line?
In the first case, the difflib module may help:
http://docs.python.org/lib/module-difflib.html
In the second case, just iterate over both files, compare lines and
display one thing or another.
> is the set function going to be the best option or is there any other way
Probably the set type won't be useful - a concrete example of what you
want would help to provide better ideas.
--
Gabriel Genellina
More information about the Python-list
mailing list