aboutsummaryrefslogtreecommitdiffstats
path: root/python/report_ops
diff options
context:
space:
mode:
Diffstat (limited to 'python/report_ops')
-rw-r--r--python/report_ops/__main__.py6
-rw-r--r--python/report_ops/wires.py49
2 files changed, 35 insertions, 20 deletions
diff --git a/python/report_ops/__main__.py b/python/report_ops/__main__.py
index 4bc1a4da..f7b43c9c 100644
--- a/python/report_ops/__main__.py
+++ b/python/report_ops/__main__.py
@@ -1,6 +1,7 @@
import logging
import argparse
import datetime
+from pandas.errors import EmptyDataError
from serenitas.analytics.dates import prev_business_day
from serenitas.utils.db import dbconn
@@ -92,7 +93,10 @@ if args.cash_reports or args.wire_reports:
for custodian in custodians:
get_custodian_download_fun(custodian)(args.date, fund, em=em)
report = Report[custodian](args.date, fund)
- report.commit()
+ try:
+ report.commit()
+ except (MissingDataError, EmptyDataError) as e:
+ logger.info(e)
if args.isosel_reports:
for fund in ("ISOSEL",):
diff --git a/python/report_ops/wires.py b/python/report_ops/wires.py
index 7d82be6c..1a806808 100644
--- a/python/report_ops/wires.py
+++ b/python/report_ops/wires.py
@@ -3,6 +3,7 @@ import re
from typing import ClassVar
from dataclasses import dataclass
import pandas as pd
+from pandas.errors import EmptyDataError
from serenitas.ops.dataclass_mapping import Fund
from serenitas.analytics.dates import prev_business_day
@@ -67,7 +68,12 @@ class WireReport(
class BNYWireReport(WireReport, custodian="BNY", dtkey="%Y%m%d%H%M%S"):
def __iter__(self):
- df = pd.read_csv(self.get_report(), thousands=",")
+ try:
+ df = pd.read_csv(self.get_report(), thousands=",")
+ except EmptyDataError as exc:
+ raise EmptyDataError(
+ f"File received no wires for {self.fund}: {self.custodian} {self.date}"
+ ) from exc
df["Local Amount"] = df["Local Amount"].apply(
lambda s: "-" + s[1:-1] if s.startswith("(") else s
)
@@ -131,25 +137,30 @@ class UMBWireReport(WireReport, custodian="UMB"):
lambda x: f'{x["Transaction Date"]}-{x["index"]}', axis=1
)
self.clear_sql_entries()
- return (
- (
- self.date,
- self.fund,
- self.custodian,
- *t,
+ if not df.iloc[0]["Transaction Date"].startswith("No records"):
+ return (
+ (
+ self.date,
+ self.fund,
+ self.custodian,
+ *t,
+ )
+ for t in df[
+ [
+ "Transaction Date",
+ "Transaction Date",
+ "Transaction Date",
+ "Local Currency Code",
+ "Net Amount",
+ "Transaction Description",
+ "Unique Ref",
+ ]
+ ].itertuples(index=False)
+ )
+ else:
+ raise EmptyDataError(
+ f"File received no wires for {self.fund}: {self.custodian} {self.date}"
)
- for t in df[
- [
- "Transaction Date",
- "Transaction Date",
- "Transaction Date",
- "Local Currency Code",
- "Net Amount",
- "Transaction Description",
- "Unique Ref",
- ]
- ].itertuples(index=False)
- )
def clear_sql_entries(self):
conn = dbconn("dawndb")