diff options
Diffstat (limited to 'python/intex/load_intex_collateral.py')
| -rw-r--r-- | python/intex/load_intex_collateral.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/python/intex/load_intex_collateral.py b/python/intex/load_intex_collateral.py index 4ee61047..b1a82e6d 100644 --- a/python/intex/load_intex_collateral.py +++ b/python/intex/load_intex_collateral.py @@ -19,9 +19,6 @@ fields = ['Asset Name', 'Issuer', 'Contributed Balance', 'Asset Maturity Date', 'Life Floor', 'Reinvest Collat', 'Native Currency', "Moody's Industry Name", "Country"] -def convertToNone(s): - return None if s=='' else s - def upload_data(conn, workdate): sql_fields = ["dealname", "updatedate", "name", "IssuerName", "CurrentBalance", "Maturity", "AssetSubtype", "AssetType", "GrossCoupon", @@ -34,7 +31,7 @@ def upload_data(conn, workdate): basedir = Path(os.environ['DATA_DIR']) / ("Collaterals_" + workdate) for fname in basedir.iterdir(): fh = open(fname, encoding="windows-1252") - dealname = fname.name.split("_", 1)[0].lower() + dealname = fname.name.rsplit("_", 1)[0].lower() dr = csv.DictReader(fh, dialect = 'excel-tab') missingfields = set(fields).union({'Gross Margin'}) - set(dr.fieldnames) if "LoanX ID" in missingfields: @@ -85,7 +82,7 @@ def upload_data(conn, workdate): '%b %d, %Y').date() except (ValueError, TypeError): line['Asset Maturity Date'] = None - r = [convertToNone(line[field]) for field in fields] + r = [line[field] or None for field in fields] #sometimes the Asset Name is not unique (we add random tag in this case) if r[0] in data: r[0] = r[0] + str(uuid.uuid4())[:3] |
