I have 10 text files in the same folder. I want to process each text file individually in a for loop.
def qwerty():
with open('file.txt') as f:
dicts = {}
for words in f:
split_words = reg.finditer(words)
for line in split_words:
group1 = line.group(1)
if group1 not in dicts:
dicts[group1] = 1
else:
dicts[group1] += 1
return dicts
This is my code to process the individual text file. How do I run a loop that would process all the text files I have one by one? So the amount of text files correspond to the number of iterations in the for loop.
from glob import globand thenfor filename in glob("*.txt").