diff options
Diffstat (limited to 'python/load_globeop_report.py')
| -rw-r--r-- | python/load_globeop_report.py | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/python/load_globeop_report.py b/python/load_globeop_report.py index f793e8ad..5ba43190 100644 --- a/python/load_globeop_report.py +++ b/python/load_globeop_report.py @@ -18,10 +18,7 @@ def get_globs(fname, years=['2013', '2014', '2015', '2016', '2017']): return globs def read_valuation_report(f): - try: - date = pd.Timestamp(f.split('/')[6]) - except ValueError: - date = pd.Timestamp(f.split('/')[4]) + date = pd.Timestamp(f.rsplit('/', 3)[1]) if date >= pd.Timestamp('2013-02-06'): df = pd.read_csv(f, parse_dates=['KnowledgeDate','PeriodEndDate']) else: @@ -59,10 +56,7 @@ def pnl_reports(): for f in chain.from_iterable(get_globs('Pnl*')): if not (f.endswith("Pnl.csv") and f.endswith("Pnl_Report.csv")): continue - try: - date = pd.Timestamp(f.split('/')[6]) - except ValueError: - date = pd.Timestamp(f.split('/')[4]) + date = pd.Timestamp(f.rsplit('/', 3)[1]) date = date - bus_day df[date] = read_pnl_report(f) df = pd.concat(df, names=['date', 'row']).reset_index() @@ -104,10 +98,7 @@ def read_cds_report(f, old_report=False): def cds_reports(): df = {} for f in chain.from_iterable(get_globs('CDS_Report')): - try: - date = pd.Timestamp(f.split('/')[6]) - except ValueError: - date = pd.Timestamp(f.split('/')[4]) + date = pd.Timestamp(f.rsplit('/', 3)[1]) old_report = date <= pd.Timestamp('2017-02-28') or date == pd.Timestamp('2017-03-02') date = date - bus_day df[date] = read_cds_report(f, old_report) |
