Tagged Questions
6
votes
4answers
2k views
Recursive diff of two python dictionaries (keys and values)
So I have a python dictionary, call it d1, and a version of that dictionary at a later point in time, call it d2. I want to find all the changes between d1 and d2. In other words, everything that was ...
0
votes
0answers
28 views
Tree-based diff (for HTML/XML) in Python 3x
I am trying to find a library that will allow to perform "tree-based" diffs, or diffs that are aware of DOM structures. I have two lists with HTML content that I want to perform differential analysis ...
1
vote
1answer
73 views
Implementing Google's DiffMatchPatch API for Python 2/3
I want to write a simple diff application in Python using Google's Diff Match Patch APIs.
I'm quite new to Python, so I want an example of how to use the Diff Match Patch API for semantically ...
-3
votes
10answers
4k views
Algorithm to detect similar documents in python script [closed]
I need to write a module to detect similar documents. I have read many papers of fingerprints of documents techniques and others, but I do not know how to write code or implement such a solution. The ...
3
votes
2answers
2k views
How to diff file and output stream “on-the-fly”?
I need to create a diff file using standard UNIX diff command with python subprocess module. The problem is that I must compare file and stream without creating tempopary file. I thought about using ...
0
votes
0answers
40 views
Python Difflib - How to Get SDiff Sequences with “Change” Op
I am reading the documentation for Python's difllib. According to the docs each, Differ delta gives a sequence
Code Meaning
'- ' line unique to sequence 1
'+ ' line unique to sequence 2
' ...
2
votes
1answer
87 views
Diffing Binary Files In Python
I've got two binary files. They look something like this, but the data is more random:
File A:
FF FF FF FF 00 00 00 00 FF FF 44 43 42 41 FF FF ...
File B:
41 42 43 44 00 00 00 00 44 43 42 41 40 ...
4
votes
1answer
1k views
Diffing a JSON document
Well, my question is a little complicated, but here goes:
I have a Python server that stores client (written in JavaScript) sessions, and has complete knowledge of what the client currently has ...
1
vote
1answer
224 views
Worst-case behaviour of Python's HtmlDiff.make_table()
I'm using Python 2.7's difflib.HtmlDiff.make_table() function to generate diffs between expected and actual files for an internal test case runner. They end up in an HTML test report.
This has worked ...
0
votes
1answer
96 views
Excel diff with python
I am looking for an algorithm to comapre two excel sheets, based on their column names, in Python.
I do not know what the columns are, so one sheet may have an additional column or both sheets can ...
0
votes
1answer
73 views
Diffing and Synchronizing 2 tables MySQL
I have 2 tables, One with new data, and another with old data.
I need to find the diff between the two tables and push only the changes into the table with the old data as it will be in production.
...
2
votes
3answers
2k views
Python binary diff
I'm trying to use bsdiff (or any binary diff implementation you come up with) to compute and apply diff onto random binary data. I would like to use it on data from a database, so it would be better ...
38
votes
11answers
10k views
Text difference algorithm
I need an algorithm that can compare two text files and highlight their difference and ( even better!) can compute their difference in a meaningful way (like two similar files should have a ...
2
votes
3answers
411 views
Comparing image in url to image in filesystem in python
Is there a quick and easy way to do such comparison?
I've found few image compare questions from stackoverflow but none of those actually proved answer for this question.
I have images files in my ...
2
votes
1answer
299 views
Diff on XML with unicode using python
I'm trying to create a web tool that can visualize the differences between two XMLs. difflib was working pretty well in creating html with the differences, but then some unicode text showed up in the ...
14
votes
3answers
538 views
Building an HTML Diff/Patch Algorithm
A description of what I'm going to accomplish:
Input 2 (N is not essential) HTML documents.
Standardize the HTML format
Diff the two documents -- external styles are not important but anything ...
0
votes
1answer
60 views
issues diffing JSON (twitter API)
I'm working on a fairly simple script that monitors and archive's a given users tweets -- right now, my configuration requests an account's 20 most recent tweets (API limit) every five minutes, then ...
8
votes
3answers
3k views
Xml comparison in Python
Building on another SO question, how can one check whether two well-formed XML snippets are semantically equal. All I need is "equal" or not, since I'm using this for unit tests.
In the system I ...
0
votes
2answers
296 views
Compare two txt files and print the difference line by line in txt file
I have two tab-delimited .txt files, and I want to compare them to each other. The end goal is to print the difference in a another .txt file, which will have only the lines where the different data ...
0
votes
0answers
89 views
Python: Visual difference widget
I'm planning to write a git client, and want to implement its UI with pygtk.
As we know, to show the different between two files is very important with respect to my project.
So, how can I make it in ...
1
vote
1answer
245 views
How do you parse a diff file created with pysvn?
Does pysvn have a way to parse diff files it creates? I want to extra the filename/filepath, head revision of each contained file, total lines changed, total files changed, etc.
If not, is there a ...
2
votes
1answer
197 views
Python: How to create diff/patch files between 2 revisions for a single URL?
I would like to create a diff (patch) file between two revisions for a single SVN URL, including lines of unified context.
Basically I need to provide a Python method to achieve the following:
URL ...
1
vote
1answer
84 views
Python: slicing elements of lists in lists in lists differently depending on sublist
I've reached the end of my limited knowledge with this problem. At the moment, I'm parsing diff results. Here's an example of the results I'm trying to manipulate:
[
[[0, 0, '\xe2\x80\x9cWe are ...
0
votes
1answer
45 views
Patch cannot proceeed one specific diff
I have got one specific file like this:
+
+ %3)+Lorem
+
+ %4)+Lorem
+
+ %5)+Lorem
+
+
I generate unified diff using ...
0
votes
1answer
156 views
Parsing diff results (list of tuples) with python
Python beginner here.
I'm working with diffs at the moment. I'm generating them with the google python library.
Here's a sample of what a diff result looks like:
[(0, 'Ok. I just '),
(-1, 'need ...
-1
votes
1answer
260 views
Avoid subprocess.Popen auto escaping my backslashes in grep
I'm trying to write an svn pre-commit hook in python. Part of this involves checking the diff file to see if there are any actual file changes (as opposed to just property changes).
I have a working ...
1
vote
2answers
140 views
python diff SequenceMatcher - patching a list
i patch a list to look like another:
a = [x for x in "qabxcd"]
b = [x for x in "abycdf"]
c = a[:]
s = SequenceMatcher(None, a, b)
for tag, i1, i2, j1, j2 in s.get_opcodes():
print ("%7s a[%d:%d] ...
0
votes
1answer
125 views
How to apply unified diff-file to origin file?
I need some function 'apply_patch':
result_string = apply_patch('origin_file.txt', 'origin_file.txt.patch')
or some commands (for windows and linux):
if linux:
result_string = ...
6
votes
5answers
3k views
Textually diffing JSON
As part of my release processes, I have to compare some JSON configuration data used by my application. As a first attempt, I just pretty-printed the JSON and diff'ed them (using kdiff3 or just ...
0
votes
5answers
159 views
Python How to check for no return
In python I want to diff two files using commands.getoutput('diff a.txt b.txt') and if they are the same, print "Success!". How would I go about writing an if statement that is satisfied if they are ...
0
votes
3answers
184 views
Get added and removed words between two strings
Given two strings, I'd like to be able to -- in Python -- be able to determine which words have been added and which words have been removed between the two. I've seen difflib, but apparently it ...
1
vote
1answer
316 views
How to apply the output of python's difflib.unified_diff to the original string?
So, using Python's difflib, I can generate a diff of two strings:
foo = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n Nullam sed orci lobortis lectus bibendum vehicula.\n Integer ...
1
vote
4answers
805 views
how to using python to diff two html files
i want use python to diff two html files:
example :
html_1 = """
<p>i love it</p>
"""
html_2 = """
<h2>i love it </p>
"""
the diff file will like this :
diff_html = """
...
1
vote
2answers
182 views
How can I have all the line in the diff using diff_match_patch?
I'm using the Google diff-match-patch library for Python.
Suppose that I compare these two files (prepend 'Z' on line 2)
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
...
1
vote
1answer
124 views
hot to use python diff html
is there a way diff html as bellow ?
html_1 = "<h1>text<h1>"
html_2 = "<h2>text<h2>"
use google's diff_prettyHtml will not work correctly .
i will say that 1 change to 2:
...
4
votes
1answer
483 views
In python, produce HTML highlighting the differences of two simple strings
I need to highlight the differences between two simple strings with python, enclosing the differing substrings in a HTML span attribute. So I'm looking for a simple way to implement the function ...
5
votes
4answers
3k views
Redirect command to input of another in Python
I would like to replicate this in python:
gvimdiff <(hg cat file.txt) file.txt
(hg cat file.txt outputs the most recently committed version of file.txt)
I know how to pipe the file to gvimdiff, ...
0
votes
3answers
372 views
Render Unified Diff with Python
I have a string which contains svn unified diff. My PyGTK app need to show this diff to user, and I want to render it like other diff tools do, or at least have it colorized.
Do you have something to ...
1
vote
3answers
550 views
Python comparing two massive sets of data in the MOST efficient method possible
I have to compare massive database dumps in xls format to parse for changes day-to-day (gross, right?). I'm currently doing this in the most backwards way possible, and using xlrd to turn the xls into ...
9
votes
2answers
341 views
Is it possible to have all “git diff” commands use the “Python diff”, in all git projects?
When including the line
*.py diff=python
in a local .gitattributes file, git diff produces nice labels for the different diff hunks of Python files (with the name of the function where the lines ...
3
votes
2answers
221 views
Mapping line numbers across two diff files using emacs/python/winmerge
Consider the following two files that are slightly different
foo(old version):
<Line 1> a
<Line 2> b
<Line 3> c
<Line 4> d
foo(new version):
<Line 1> a
<Line ...
1
vote
2answers
434 views
Online file comparison tool
I want to a visualize web file compare tool,that can embed into my app,I know there some software like beyond compare,it has done great job,but it on windows & need buy licence,if someone has ...
1
vote
2answers
645 views
Is there a Python API for drawing diagrams (that use lines to connect corresponding values between two lists)
Given two lists, which contain same elements of string but in different orders, is there any API that can draw diagrams like
The diagram consists of two stacks of string. Between these two stacks, ...
1
vote
1answer
336 views
Automating a directory diff while ignoring some particular lines in files
I need to compare two directories, and produce some sort of structured output (text file is fine) of the differences. That is, the output might looks something like this:
file1 exists only in ...
0
votes
1answer
278 views
rdiff python module
Is there a python module that has the functionality for computing rdiff signatures and delta differencing?
I need to perform these operations on a cross-platform application so I'll need something ...
0
votes
1answer
394 views
Diffing two folders (like the diff tool in Linux) with Python
I'm trying to write a project that will have some autonomous components. One of these is the need to diff two folders and spit out the different files into an array of strings. Dircmp does part of ...
2
votes
6answers
1k views
Get the diff of two MSWord doc files and output to html [duplicate]
Possible Duplicate:
How to compare two word documents?
How can you get the diff of two word .doc documents programatically?
Where you can then take the resulting output and generate an html ...
1
vote
1answer
600 views
diff algorithm implementation in python
Hi all:
I checked out the source code of Python 2.6, and I want to study the diff implementation in python. However, I can not find the right source file.
Could any one give me some information which ...
1
vote
1answer
116 views
Is that possible to restore a text given unified diff and the original text with python
What I want is to calculate the diff delta of two texts(original and new), store the original text the delta, then expect to restore the new text. So that I can store different versions of one text ...
0
votes
2answers
386 views
patching text files
I'm trying to successively build up a text file with diff patches.
starting from an empty text file I need to apply 600+ patches to end up with the final document (a text I have written + tracked the ...