The PDFs parse very reasonably into text, so we do the bare minimum with pypdf. It will be easier to edit things like broken lines or irrelevant text by hand later than to code these adjustments (and risk having them break on next year's versions anyway).
17 lines
475 B
Python
17 lines
475 B
Python
from pathlib import Path
|
|
|
|
from pypdf import PdfReader
|
|
|
|
|
|
srcdir = Path("sources")
|
|
outdir = Path("derived")
|
|
outdir.mkdir(exist_ok=True)
|
|
|
|
for fname in ("faechersystematik-stabu.pdf", "subject-classification-stabu.pdf", "personal-stellenstatistik.pdf"):
|
|
src_file = srcdir / fname
|
|
out_file = (outdir / fname).with_suffix(".txt")
|
|
reader = PdfReader(src_file)
|
|
text = ""
|
|
for page in reader.pages:
|
|
text += page.extract_text()
|
|
out_file.write_text(text)
|