I would like to compare the dat of two files and store the report in another file.I tried using winmerge by invoking cmd.exe using subprocess module in python3.2.i was able to get the difference report but wasnt able to save that report.Is there a way with winmerge or with any other comparing tools(diffmerge/kdiff3) to save the difference report using cmd.exe in windows7?please help
-
possible duplicate of [Comparing two text files in python](http://stackoverflow.com/questions/3043026/comparing-two-text-files-in-python) – Oleh Prypin Jun 14 '12 at 09:08
-
i intend to use a tool.e.g-winmerge provides the difference report in a very nice and informative way.I have done it using difflib but i would like to see both my input files side by side with the visual highlighting of the differences and not in(+,-,?) which difflib does.I am not being able to save it.winmerge has an option to merge the output and save it but i dont want to merge. – mayank Jun 14 '12 at 09:36
-
if i could pass keyboard commands like alt+t and then a name and then enter using python and command line into the GUI it would serve my purpose – mayank Jun 14 '12 at 09:38
1 Answers
Though your question is quite old, I wonder it wasn't answered yet. I was searching myself for an answer and funnily I found yours. Perhaps you mix quite a lot questions into one mail. So I decided to answer the main headline, where I suppose you try to compare human readable file contents.
To compare two files, there is a difflib library which is part of the Python distribution.
By the way an example how to generate a utility to compare files can be found on Python's documentation website.
The link is here: Helpers for computing deltas
From there you can learn to create an option and save deltas to a e.g. textfile or something. Some of these examples contain also a git-difference-like output, which possibly helps you to solve your question.
This means, if you are able to execute your script, then other delta tools are not required. It makes not soo much sense to call other tools via Python on CMD and try to control them... :)
Maybe also this Website with explanations and code examples may help you: difflib – Compare sequences
I hope that helps you a bit.
EDIT: I forgot to mention, that the last site contains a straightforward example how to generate an HTML output: HTML Output

- 783
- 2
- 17
- 38