aboutsummaryrefslogtreecommitdiffstats
path: root/python/citco.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/citco.py')
-rw-r--r--python/citco.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/python/citco.py b/python/citco.py
index ab5d9aec..cf8aaebe 100644
--- a/python/citco.py
+++ b/python/citco.py
@@ -3,6 +3,7 @@ from serenitas.utils.env import DAILY_DIR
from serenitas.utils.db import dawn_engine, dbconn
from serenitas.utils.remote import SftpClient
import datetime
+from serenitas.analytics.dates import prev_business_day
def load_citco_report(fdir):
@@ -10,7 +11,7 @@ def load_citco_report(fdir):
df["row"] = df.index
df.columns = df.columns.str.lower()
df.columns = df.columns.str.replace(" ", "_")
- df["period_end_date"] = pd.to_datetime(df["period_end_date"])
+ df["period_end_date"] = pd.to_datetime(df["period_end_date"], format="%Y%m%d")
return df
@@ -26,6 +27,9 @@ if __name__ == "__main__":
df = load_citco_report(reports_dir / f"Valuation_Report_ISOSEL.csv")
conn = dbconn("dawndb")
with conn.cursor() as c:
- c.execute("DELETE from citco_reports where period_end_date =%s", (date,))
+ c.execute(
+ "DELETE from citco_reports where period_end_date =%s",
+ (prev_business_day(date),),
+ )
conn.commit()
df.to_sql("citco_reports", dawn_engine, if_exists="append", index=False)