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

Python program to compare two files for showing the difference

I have the following code to compare two files. I would like this program run if I point them to files which are as big as 4 or 5 MB. When I do that, the prompt cursor in python console just blinks, and no output is shown. Once, I ran it for the…
MiniGunnR
  • 5,590
  • 8
  • 42
  • 66
0
votes
2 answers

Django two files upload for difference

I have already posted in https://stackoverflow.com/questions/26776003/how-to-use-htmldiff-in-django-to-show-difference-of-two-uploaded-files However, I want to know if there is an easy way to upload a couple of files and submit which shows the…
MiniGunnR
  • 5,590
  • 8
  • 42
  • 66
0
votes
1 answer

Python difflib with regex

I would like to compare a string A with a regex R. A = u'Hi my friend, my name is Julio' R = r'Hi\s+my\s+friend,\s+my\s+name\s+is([A-Za-z]+)' At this time I can easily know if the syntax is good thanks to re.matchand re.search. Now I would like to…
Julio
  • 2,493
  • 4
  • 33
  • 53
0
votes
1 answer

Python dataframes

I have a dataframe (df) and trying to append data to a specific row Index Fruit Rank 0 banana 1 1 apple 2 2 mango 3 3 Melon 4 The goal is to compare the Fruit at Rank 1 to each rank and then append the…
BlackHat
  • 736
  • 1
  • 10
  • 24
0
votes
1 answer

Efficient data structure for searching a dictionary of words in python using difflib?

I am trying to write a spellchecker and I wanted to use difflib to implement it. Basically I have a list of technical terms that I added to the standard unix dictionary (/usr/share/dict/words) that I'm storing in a file I call dictionaryFile.py. I…
user3058197
  • 1,052
  • 1
  • 9
  • 21
0
votes
1 answer

Compare two phrases using WordNet?

I am trying to compare the semantic of two phrases. In Python I am using nltk and difflib. First I am removing the stop words from the phrases, then I am using WordNetLemmatizer and PorterStemmer to normalise the words then I am comparing the rest…
Rami
  • 8,044
  • 18
  • 66
  • 108
0
votes
1 answer

Find equal sequence from 10 lines strings

I'm trying find longest common sequence from text file, which contains string lines. Output should be also text file with align lines like in example: find sequence - efghijk output file: abcdefghijklmno dfefghijkrumlp swrefghijkawsfce …
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
  • 2
  • 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
  • 2
  • 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,561
  • 1
  • 13
  • 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,379
  • 4
  • 28
  • 64
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
  • 973
  • 4
  • 14
  • 35
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
  • 531
  • 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
  • 5,505
  • 13
  • 43
  • 62
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
  • 779
  • 1
  • 8
  • 19
1 2 3
22
23