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
3 answers

Compare two strings in python

well i need to compare two strings or at least find a sequence of characters from a string to another string. The two strings contain md5 of files which i must compare and say if i find a match. my current code is: def comparemd5(): …
scandalous
  • 912
  • 5
  • 14
  • 25
0
votes
3 answers

Use set differences to get line number of missing values

I have two lists which I use the following function to assign line numbers (similar to nl in unix): def nl(inFile): numberedLines = [] for line in fileinput.input(inFile): numberedLines.append(str(fileinput.lineno()) + ': ' + line) …
KennyC
  • 445
  • 1
  • 9
  • 16
0
votes
1 answer

Unexplaned behavior with difflib.SequenceMatcher get_matching_blocks()

I was experimenting with fuzzywuzzy and encountered that for quite a few cases it was generating wrong result. I tried to debug and encountered a scenario with get_matching_blocks() which was difficult to explain. My understanding of…
Abhijit
  • 62,056
  • 18
  • 131
  • 204
-1
votes
1 answer

Changing hashed passwords with similarity check

I have hashed passwords stored in my database and I want to implement a password change function. Before updating the password, I want to check how similar the old and new passwords are. I have used the difflib library to compare the two values, but…
ussrback
  • 491
  • 2
  • 8
  • 22
-1
votes
2 answers

Finding best matching string from a list of strings

Been trying to find the closest match to a string from a list of strings. I've used "difflib" module : https://docs.python.org/3/library/difflib.html but the results not always as expected. Example: import difflib words_list =…
tumir
  • 39
  • 1
  • 7
-1
votes
1 answer

Difflib throwing error on tags that don't change

I'm having a weird issue with difflib. I'm trying to pull out the differences between two urls, grouped by html tag in a list. This works fine on a subset of the html -- if there was an actual change, or if the tag didn't exist -- but is not working…
jonsurfs
  • 3
  • 2
-1
votes
1 answer

Similarity between lists of floats

I have a list of floats that I want to compare to other lists and get the similarity ratio in python : The list that I want to compare: [0.0000,0.0003,-0.0001,0.0002, 0.0001,0.0003,0.0000,0.0000, -0.0002,0.0002,-0.0002,0.0002,…
Elyes Lounissi
  • 405
  • 3
  • 12
-1
votes
1 answer

difflib.SequenceMatcher not returning unique ratio

I am trying to compare 2 street networks and when i run this code it returns a a ratio of .253529... i need it to compare each row to get a unique value so i can query out the streets that dont match. What can i do it get it to return unique ratio…
-2
votes
0 answers

Python how does difflib accuracy differs from spact

hello I need to know what needsto be done here The choice between difflib and libraries like spaCy for text similarity depends on your specific use case and requirements. Let's delve into the differences between them and the factors to consider when…
-2
votes
1 answer

Failing to write output of HtmlDiff containing unicode text in python 3

I am trying to compare two Arabic strings using python's difflib.HtmlDiff module. I have looked at various ways of writing the outputs of HtmlDiff to a file but none seems to work for me. Methods I have tried so far: Note: in all subsequent code…
Sнаđошƒаӽ
  • 16,753
  • 12
  • 73
  • 90
-4
votes
1 answer

Calculating string difference in python

I am trying to calculate the number of characters that differ between two strings in python. Ideally I want a function just like strdif in C. I see ndiff in python's difflib, but that returns a Differ object whereas I want a simple integer (ex:…
1 2 3
22
23