lehr-und-forschungsbereiche/parse-pdfs.py
Michał Szczepanik 006c728bce Add code for parsing the PDFs
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).
2026-07-22 17:05:43 +02:00

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)