This commit is contained in:
2025-10-22 16:45:33 +02:00
parent 6d2b4e9858
commit d8d3de7949
6 changed files with 255 additions and 81 deletions

31
70 PDF read ZPMVCR.py Normal file
View File

@@ -0,0 +1,31 @@
import pdfplumber
import pandas as pd
from pathlib import Path
pdf_path = Path(r"u:\Dropbox\!!!Days\Downloads Z230\prehled 09_2025 zpmvcr.pdf")
xlsx_path = pdf_path.with_suffix(".xlsx")
all_tables = []
with pdfplumber.open(pdf_path) as pdf:
for i, page in enumerate(pdf.pages, start=1):
tables = page.extract_tables()
if not tables:
continue
table = tables[0]
# Convert to DataFrame, first row = header
df = pd.DataFrame(table[1:], columns=table[0])
df["page"] = i
all_tables.append(df)
if not all_tables:
print("❌ No tables found.")
else:
df_all = pd.concat(all_tables, ignore_index=True)
print("✅ Combined shape:", df_all.shape)
print(df_all.head())
# Save to Excel
df_all.to_excel(xlsx_path, index=False)
print(f"💾 Saved to: {xlsx_path}")