aboutsummaryrefslogtreecommitdiffstats
path: root/python/task_server/insert_tranche_quotes.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/task_server/insert_tranche_quotes.py')
-rw-r--r--python/task_server/insert_tranche_quotes.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/python/task_server/insert_tranche_quotes.py b/python/task_server/insert_tranche_quotes.py
index 251d60bf..632304bd 100644
--- a/python/task_server/insert_tranche_quotes.py
+++ b/python/task_server/insert_tranche_quotes.py
@@ -5,6 +5,8 @@ import csv
import datetime
import logging
+logger = logging.getLogger(__name__)
+
engine = create_engine('postgresql://serenitas_user@debian/serenitasdb')
metadata = MetaData(bind = engine)
quotes = Table('tranche_quotes', metadata, autoload = True)
@@ -30,11 +32,15 @@ def insert_quotes(year=2015, quote_dir=None):
reader = csv.DictReader(fh)
data = []
for csvdict in reader:
- try:
- timestamp = datetime.datetime.strptime(csvdict['Date'], "%d %b %Y %H:%M")
- except ValueError:
- logging.error("%s: Date in the wrong format", csvdict['Date'])
- return
+ for p in ["%d %b %Y %H:%M", "%m/%d/%Y %H:%M"]:
+ try:
+ timestamp = datetime.datetime.strptime(csvdict['Date'], p)
+ break
+ except ValueError:
+ logger.error("%s: Date in the wrong format", csvdict['Date'])
+ continue
+ else:
+ logger.error("%s: Date in the wrong format", csvdict['Date'])
attach = int(csvdict['Attach'])
series = int(csvdict['Series'])