-1

The program is supposed to scrape a bunch of text file with a regex pattern and through the results into an excel file. From what I can tell, if I uncomment the for statement specifically, it'll go ahead and make the xlsx file. If I uncomment everything in the for loop, it still does nothing.

I don't know why the presence of a loop would prevent something like this from working.

master_list_of_strings = []

cwd = pathlib.Path('./target')
# for filename in cwd.rglob('*'):
for filename in cwd.iterdir():
    if filename.is_dir():
        continue
    if filename.suffix == 'py':
        continue
    if filename.suffix == 'xlsx':
        continue
    if filename.suffix == 'xls':
        continue

    text = filename.read_text('utf-8', 'ignore')

    pattern = r"obj.translate_this\(('.+?)(?=')"

    lifted_strings = re.findall(pattern, text)
    master_list_of_strings += lifted_strings

book = Workbook()
book.save('translation_strings.xlsx')

I expect the creation of an xlsx file instead, the program exits without an error, but no file was created.

1 Answers1

0

I was using openpyxl today and getting suffix like you are. But it returned the dot as well as extension. So would it help if you checked for == ".xlsx"