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.

271 questions
0
votes
1 answer

difflib.get_close_matches throw out names in a list if first answer isn't correct

Here's an updated version from my previous question here. I'm adding to the code where if the get_close_matches name isn't the name of the person they wanted, then discard the closest match and re-run the function and grab the second-closest match…
user3259628
  • 5
  • 1
  • 5
0
votes
1 answer

difflib.get_close_matches() - Help getting desired result

The basic gist of the program is to start with a list of employee names, then sort it. Wait for user to input "end" to stop populating the list of names (I have 100 names, I cut it short for the example). Afterwards, the user can enter an employee…
user3259628
  • 5
  • 1
  • 5
0
votes
0 answers

comparing two texts in python difflib

A riddle of sorts….I have two text similar text files containing file paths for data that I have downloaded and another for data that I would like to download as part of an automated periodic process. I would however only like to download the new…
Chase CB
  • 1,131
  • 1
  • 11
  • 20
0
votes
1 answer

Extrapolating diffs with python

i'm using a library to extrapolate the diffs between two json files. My code loads them into dictionaries and then uses datadiff to get the difference between the two data structure. The problem is that i want to process further the output…
softwareplay
  • 1,241
  • 3
  • 22
  • 62
0
votes
2 answers

Remove nearly duplicate string from a list of strings using Difflib

I am using python and mysql. Here is my code cur.execute("SELECT distinct product_type FROM cloth_table") Product_type_list = cur.fetchall() Now Product_type_list is a list of strings describing the product_type like this product_type_list…
Binit Singh
  • 923
  • 2
  • 14
  • 30
0
votes
1 answer

python appending items in a dictionary with for loop

I am writing a nested for loop to judge if two words are similar in pronunciation. My code is like below: wordsDict = nltk.defaultdict(list) for s1 in prondict[word1]: for s2 in prondict[word2]: sm=difflib.SequenceMatcher(None, s1, s2) …
noben
  • 451
  • 1
  • 7
  • 16
0
votes
1 answer

How is python's difflib.find_longest_match implemented?

Originally wanted an algorithm to find the longest substring between two python Strings. The general answer for the best runtime was "to construct a suffix tree", based on the online consensus for a linear runtime. However, there are zero examples…
Lucas Ou-Yang
  • 4,595
  • 11
  • 37
  • 58
0
votes
2 answers

Compare two multiple-column csv files

[Using Python3] I want to compare the content of two csv files and let the script print if the contents are the same. In other words, it should let me know if all lines are matched and, if not, the number of rows that are mismatched. Also I would…
Matthijs
  • 609
  • 1
  • 8
  • 18
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
  • 840
  • 4
  • 12
  • 21
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
  • 405
  • 1
  • 7
  • 15
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
  • 55,716
  • 14
  • 105
  • 186
-1
votes
2 answers

Getting a TypeError: 'float' object is not iterable when using a list of strings

Im trying to get the closest match between two lists of strings (listA and listB) to create a listC. The purpose for that is because I have to clean a dataframe that has one column of strings which each string represent a fruit which some entries…
-1
votes
2 answers

What's the use of cutoff argument in difflib.get_close_matches example in python?

In difflib.get_close_matches(word, possibilities[, n][, cutoff]), whats the use of cutoff here. How it affects the word matches?
Sana Jain
  • 5
  • 2
-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
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наđошƒаӽ
  • 13,406
  • 11
  • 67
  • 83
1 2 3
18
19