code-travail/code-travail-pdf2text.py

16 lines
376 B
Python
Raw Normal View History

2024-01-03 21:40:11 +00:00
from pypdf import PdfReader
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
reader = PdfReader(f"{dir_path}/sources/code-travail-2022.pdf")
full_text = ""
for page in reader.pages:
text = page.extract_text()
full_text += "\n"
full_text += text
with open(f"{dir_path}/sources/code-travail-2022.txt", "a") as myfile:
myfile.write(full_text)