Trying to write a code that will compare multiple files and return the highest fuzzratio between multiple options.
Problem is I'm getting an error message:
WARNING:root:Applied processor reduces input query to empty string, all comparisons will have score 0. [Query: '/'] WARNING:root:Applied processor reduces input query to empty string, all comparisons will have score 0. [Query: '.']
And the exported file is essentially blank. Any clue why this is happening?
from fuzzywuzzy import fuzz, process
import csv
def readfile( filen ):
with open(filen,'r') as f:
contents = f.readlines()
return contents
def write_fuzzy( fileo, file1, file2 ):
matches=[]
for item1 in file1:
matches.append(process.extract( str(item1), file2, limit=2 )[0][0])
with open( fileo, 'w' ) as f:
w = csv.writer( f, delimiter = ',' )
w.writerows( matches )
filenames = ['Documents/test_CSV_1.csv',\
'Documents/test_CSV_2.csv']
file_contents = []
for filen in filenames:
file_contents.append( readfile( filen ) )
write_fuzzy( 'out.csv', filenames[0], filenames[1] )