diff options
| -rw-r--r-- | python/collateral/jpm.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/python/collateral/jpm.py b/python/collateral/jpm.py index 22753570..52b2e26f 100644 --- a/python/collateral/jpm.py +++ b/python/collateral/jpm.py @@ -1,4 +1,5 @@ import logging +import msoffcrypto import pandas as pd from io import BytesIO from pikepdf import Pdf @@ -72,8 +73,14 @@ def download_files(em, count=20, *, fund="BowdSt", **kwargs): p = DATA_DIR / fname if not p.exists(): stream = BytesIO(attach.content) - pdf = Pdf.open(stream, password=passwords[fund]) - pdf.save(p) + if fname.endswith("pdf"): + pdf = Pdf.open(stream, password=passwords[fund]) + pdf.save(p) + else: + xl_file = msoffcrypto.OfficeFile(stream) + xl_file.load_key(password=passwords[fund]) + with p.open("wb") as fh: + xl_file.decrypt(fh) def collateral(d, dawn_trades, *, fund="BowdSt", **kwargs): |
