Aug-14-2022, 08:57 PM
Your problem is that first you do this:
for f in os.listdir(path): if f.endswith('.docx'): files.append(f) for i in range(len(files)): text = docx2txt.process(files[i]) text2 = text.replace(":", " ") text3 = text2.replace(",", " ") text4 = text3.replace("_", " ") data = text4.split()Then later on you do this:
#Sends vet list to string for j in data: vet += j + ", "Was it your plan for vet to concatenate the results for all the files? That is not what happens. Your program only uses data from the last docx file. You should combine finding, processing and appending into one loop. Like this:
vet = "" for f in os.listdir(path): if f.endswith('.docx'): text = docx2txt.process(f) text = text.replace(":", " ") text = text.replace(",", " ") text = text.replace("_", " ") data = text.split() vet += ", ".join(data)