20 lines
724 B
Python
20 lines
724 B
Python
|
|
"""Check why some multi-page PDFs aren't being imported."""
|
||
|
|
import pdfplumber
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
pdfs = ["JEI Supplier Invoice.pdf", "Supplier Invoices.pdf",
|
||
|
|
"JEI Drilling Invoices.pdf", "JEI SA Invoice 147842.pdf",
|
||
|
|
"JEI SA Proforma 148931.pdf", "newJEI Drilling Invoices (1).pdf"]
|
||
|
|
for name in pdfs:
|
||
|
|
p = Path("invoices") / name
|
||
|
|
if not p.exists():
|
||
|
|
print(f"NOT FOUND: {name}")
|
||
|
|
continue
|
||
|
|
try:
|
||
|
|
with pdfplumber.open(p) as pdf:
|
||
|
|
for i, page in enumerate(pdf.pages):
|
||
|
|
t = page.extract_text() or ""
|
||
|
|
print(f" {name:<45} page {i+1}/{len(pdf.pages)}: {len(t):>5} chars")
|
||
|
|
except Exception as e:
|
||
|
|
print(f" ERR {name}: {e}")
|