import pandas as pd from . import DAILY_DIR def download_files(count=20): from exchange import ExchangeMessage em = ExchangeMessage() emails = em.get_msgs( path=["NYops", "Margin calls CS"], count=count, subject__contains="Margin" ) DATA_DIR = DAILY_DIR / "CS_reports" for msg in emails: for attach in msg.attachments: fname = attach.name if fname.endswith("xlsx"): p = DATA_DIR / fname if not p.exists(): p.write_bytes(attach.content)