Questions tagged [difflib]

A python module, provides tools for computing and working with differences between sequences, especially useful for comparing text. Includes functions that produce reports using several common difference formats.

A python module which provides classes and functions for comparing sequences. It can be used for example, for comparing files, and can produce difference information in various formats, including HTML and context and unified diffs.

341 questions
0
votes
0 answers

Memory Error for SequenceMatcher in python

I have a big file with a list of words, some of which are not exactly correct. Ex -- (moistuizer for moisturizer, frm for from, farrr for far etc). I am using the SequenceMatcher in python to distinguish between these words and get me the correct…
M PAUL
  • 1,228
  • 2
  • 13
  • 21
0
votes
0 answers

Using difflib to detect missing characters

I've created a program to take in a password and tell the user by how many characters the password is wrong. To do this I've used difflib.Differ(). However I'm not sure how to create another loop to make it also be able to tell my how many…
Cyanidies
  • 57
  • 1
  • 2
  • 9
0
votes
1 answer

Using Difflib to combine Excel sheets

I have been trying to merge two excel sheets together based on their own name columns. I used this as a reference. In df1 the name column is Local Customer df2 the name column is Client import difflib import pandas as pd path= …
Rukgo
  • 121
  • 1
  • 13
0
votes
1 answer

Why after using difflib on unicode string I get KeyError

I tried to use difflib to compare words and sentences (in this case something like dictionary) and when I try to compare difflib output with keys in dictionary I get KeyError. Can anyone explain to me why this happens? When I'm not using difflib…
Gunnm
  • 974
  • 3
  • 10
  • 21
0
votes
1 answer

Print the number of line in a python difflib file

I am trying to find the difference between 2 text files using difflib in Python. I am able to print text which have been added or removed in the new file. But I want to print in which line the modification has been made. Even though I know how to…
0
votes
1 answer

Comparing HTML with difflib

I'm looking to get reliable diffs of content only (structural changes will be rare and therefore can be ignored) of this page. More specifically, the only change I need to pick up is a new Instruction ID added: To get a feel for what difflib will…
Pyderman
  • 14,809
  • 13
  • 61
  • 106
0
votes
1 answer

How to diff between two HTML codes?

I need to run a diff mechanism on two HTML page sources to kick out all the generated data (like user session, etc.). I wondering if there is a python module that can do that diff and return me the element that contains the difference (So I will…
Dan
  • 829
  • 2
  • 12
  • 23
0
votes
1 answer

Compare string in 2 differents files python

I need your help because after some long research I didn't find the appropriate answer to my problems. I have 2 files which contain some information. Some of this information are similar others are different. The first file is sorted the second one…
CRC
  • 27
  • 8
0
votes
1 answer

Find the closest match between two string variables using difflib

))Hi all, I would like to find the closest match between two string variables using difflib, this is my case... varA = 'plainmountain' varB = 'skymountain' newVarA = 'piaimauntain' I would like to difflib to find the closest match in VarA and VarB…
Natysiu16
  • 326
  • 1
  • 6
  • 12
0
votes
1 answer

Subtract List B from List A, but keeping the List A index and using difflib string similarity

I need some help with Python. This is not the classic subtract List B from List A to make List C. Instead I would like to look at the indexes of the items in List A (city names in a single word) that are not in List B, and store them into a new List…
litu16
  • 173
  • 5
  • 14
0
votes
1 answer

Trying to compare files opened using 'with open...' in Python 2.4 gives a SyntaxError

How can I compare two files in Python 2.4.4? The files could be different lengths. We have Python 2.4.4 on our servers. I would like to use the difflib.unified_diff() function but I can't find examples that work with Python 2.4.4. All the versions…
0
votes
1 answer

Programmatically figuring out if translated names are equivalent

I'm trying to see if two translated names are equivalent. Sometimes the translation will have the names ordered differently. For example: >>> import difflib >>> a = 'Yuk-shing Au' >>> b = 'Au Yuk Sing' >>> seq=difflib.SequenceMatcher(a=a.lower(),…
David542
  • 104,438
  • 178
  • 489
  • 842
0
votes
1 answer

Python difflib reporting unwanted difference

I am trying to compare two sequences using difflib.Differ(). However, I am observing some unwanted differences which I am not able to understand. Can someone please explain this behavior and how this can be resolved? import difflib a = "abc-123…
sarbjit
  • 3,786
  • 9
  • 38
  • 60
0
votes
1 answer

Comparing two HTML files and return the HTML tags that differ between the two

I am writing a web monitoring script using python that will look at a archived version of the page, compare it to the current, online version, and notify me if there are any changes. I have the basics of this working, but am running into a problem…
Butters
  • 887
  • 1
  • 8
  • 28
0
votes
1 answer

Observe changes in a text?

I have the following problem. I changed some parts of a online articel. Afterwards, other people start editing this online articel. Now I'm trying program a code with python that identify, if the guys after me, changed something (and how much,…