diff options
Diffstat (limited to 'python/load_indicative.py')
| -rw-r--r-- | python/load_indicative.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/python/load_indicative.py b/python/load_indicative.py index 8ee2d222..21a7503c 100644 --- a/python/load_indicative.py +++ b/python/load_indicative.py @@ -1,6 +1,5 @@ import psycopg2 import os -import os.path import datetime from datetime import date import csv @@ -10,17 +9,17 @@ from common import root from db import conn, query_db, with_connection def convertToNone(s): - return None if s=="" or s=="-" or s=="NR" else s + return None if s in ["", "-", "NR"] else s def sanitize_float(intex_float): - if intex_float.count(".") > 1: - raise ValueError - intex_float = intex_float.replace(",", "") - if "(" in intex_float: - intex_float = - float(intex_float[1:-1]) - else: - intex_float = float(intex_float) - return intex_float + try: + intex_float = intex_float.replace(",", "") + if "(" in intex_float: + intex_float = - float(intex_float[1:-1]) + else: + intex_float = float(intex_float) + except (AttributeError, ValueError): + return intex_float @with_connection def upload_cusip_data(conn, filename): |
