Aug-02-2021, 02:35 PM
extract is going to return a list of matches ordered by score. If line contains only 1 string, process will return that string along with the score. You can see this with a small mod to your script.
from fuzzywuzzy import fuzz, process import os for file in os.listdir('C:/Users/mydirectory'): with open('C:/Users/mydirectory/'+file) as f: for num,line in enumerate(f): print(process.extract("john", line)) f.close()I think ratio is a better choice for what you are doing. Or if you want the best match, use process with a list of all the files in the folder. And then use the weight to determine if the best match is good enough.