diff options
Diffstat (limited to 'python/load_intex_collateral.py')
| -rw-r--r-- | python/load_intex_collateral.py | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/python/load_intex_collateral.py b/python/load_intex_collateral.py index cd83166d..b54cd30e 100644 --- a/python/load_intex_collateral.py +++ b/python/load_intex_collateral.py @@ -25,9 +25,6 @@ def windows1252_encoder(fh): def upload_data(conn, dealnames, workdate): for dealname in dealnames: - #dealname, updatedate = line.rstrip().split() - # updatedate = datetime.datetime.strptime(updatedate, '%m/%d/%Y') - #dealname = dealname.upper() + ",AD.txt basedir = os.path.join(root, "data", "Collaterals_" + workdate) if sys.version_info[0]==2: fh = open(os.path.join(basedir, dealname.upper() + "_AD.txt")) @@ -38,31 +35,24 @@ def upload_data(conn, dealnames, workdate): dr = csv.DictReader(fh, dialect = 'excel-tab') missingfields = set(fields).union({'Gross Margin'}) - set(dr.fieldnames) if "LoanX ID" in missingfields: - msg = "{0}: LoanX ID column is missing. Probably an error in exporting from intex".format(dealname) - logging.warning(msg) + msg = "{0}: LoanX ID column is missing. Probably an error in exporting from intex" + logging.warning(msg.format(dealname)) data = {} for line in dr: for f in missingfields: line[f] = None - if line['LoanX ID']: - line['LoanX ID'] = line['LoanX ID'].upper() - if len(line['LoanX ID']) > 8: - logging.warning("dubious id found: {0}".format(line['LoanX ID'])) - line['LoanX ID'] = line['LoanX ID'][:8] - if line['Fixed or Float']: - line['Fixed or Float'] = line['Fixed or Float'].upper() - if line['CUSIP']: - line['CUSIP'] = line['CUSIP'].upper() - if len(line['CUSIP']) > 9: - logging.warning("dubious CUSIP found: {0}".format(line['CUSIP'])) - line['CUSIP'] = line['CUSIP'][:9] + for key in ['LoanX ID', 'CUSIP', 'Fixed or Float']: + if line[key]: + line[key] = line[key].upper() if line['Asset Subtype']: line['Asset Subtype'] = line['Asset Subtype'].replace("Reinvest ", "").replace("Reinv ","") - if len(line['Asset Subtype'])>10: - line['Asset Subtype'] = line['Asset Subtype'][:9] + for key, l in [('LoanX ID', 8) ('CUSIP', 9), ('Asset Subtype', 10)]: + if line[key]: + if len(line[key]) > l: + logging.warning("dubious {0} found: {1}".format(key, line[key])) + line[key] = line[key][:l] - if 'Reinvest Collat' not in missingfields and \ - line['Reinvest Collat'].upper() == 'Y' or line['Issuer'] == '': + if line['Reinvest Collat'].upper() == 'Y': # assume it's a reinvestment asset line['Reinvest Collat'] = True line['Issuer'] = line['ID Number'] |
