I have like 100+ file in directory and I need to find out which files contain the word in Thai that I looking for
Thank you
I try this but it doesn't work `
import pandas as pd
import re
import os
FOLDER_PATH = r'C:\Users\project'
list = os.listdir(FOLDER_PATH)
def is_name_in_csv(word,csv_file):
with open(csv_file,"r") as f:
data = f.read()
return bool(re.search(word, data))
word = "บัญชีรายรับ"
for csv_file in list:
if is_name_in_csv(word,csv_file):
print(f"find the {word} in {csv_file}")
`
You don't need regex. You can simply check if
word in fileContents
. Also, I changedlist
topaths
becauselist
is a built-in python keyword.