aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/bowdst.py29
1 files changed, 20 insertions, 9 deletions
diff --git a/python/bowdst.py b/python/bowdst.py
index 47b6577d..4538e8af 100644
--- a/python/bowdst.py
+++ b/python/bowdst.py
@@ -1,6 +1,7 @@
import datetime
import pandas as pd
import pathlib
+import warnings
from exchangelib import FileAttachment
from io import StringIO
from typing import Tuple
@@ -19,15 +20,25 @@ def download_messages(em):
if msg.sender == "notify@bnymellon.com":
for attach in msg.attachments:
fname = attach.name
- if fname.endswith("csv") and (
- fname.startswith("Asset Detail")
- or fname.startswith("Net Investment")
- or fname.startswith("Settled Cash")
- or fname.startswith("BowdstWires")
- ):
- date = datetime.datetime.strptime(
- fname.split("_")[1].split(".")[0], "%d %b %Y"
- ).date()
+ if fname.endswith("csv"):
+ base_name = fname.removesuffix(".csv")
+ file_type, date_part = base_name.split("_")
+ match file_type:
+ case (
+ "Asset Detail"
+ | "Net Investment Earned Income by Security"
+ | "Settled Cash Statement"
+ ):
+ date = datetime.datetime.strptime(
+ date_part, "%d %b %Y"
+ ).date()
+ case "BowdstWires":
+ date = datetime.datetime.strptime(
+ date_part, "%d %b %Y%H%M%S"
+ ).date()
+ case _:
+ warnings.warn(f"Unknown report type {file_type}")
+ continue
p = DAILY_DIR / str(date) / "Reports" / fname
if not p.parent.exists():
p.parent.mkdir(parents=True, exist_ok=True)