Feat: make from_pdf importable and move plumber in it
This commit is contained in:
parent
0fc39ed317
commit
ab2fdb0541
@ -0,0 +1 @@
|
||||
from .extract import from_pdf
|
@ -38,8 +38,9 @@ def catch_malformed_table(tables):
|
||||
return tables[0]
|
||||
|
||||
|
||||
def from_pdf(pdf):
|
||||
def from_pdf(pdf_file):
|
||||
"""Build dataframes one about charges and another on loc"""
|
||||
pdf = pdfplumber.open(pdf_file)
|
||||
recapitulatif_tables = []
|
||||
loc_tables = []
|
||||
charge_tables = []
|
||||
@ -90,8 +91,7 @@ def extract_save(pdf_file, dest):
|
||||
xls_charge = Path(dest) / f"{pdf_file.stem.replace(' ', '_')}_charge.xlsx"
|
||||
xls_locataire = Path(dest) / f"{pdf_file.stem.replace(' ', '_')}_locataire.xlsx"
|
||||
|
||||
pdf = pdfplumber.open(pdf_file)
|
||||
df_charge, df_loc = from_pdf(pdf)
|
||||
df_charge, df_loc = from_pdf(pdf_file)
|
||||
|
||||
df_charge.to_excel(xls_charge, sheet_name="Charges", index=False)
|
||||
logging.info(f"{xls_charge} saved")
|
||||
|
Loading…
Reference in New Issue
Block a user