aboutsummaryrefslogtreecommitdiffstats
path: root/python/parse_emails.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/parse_emails.py')
-rw-r--r--python/parse_emails.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/python/parse_emails.py b/python/parse_emails.py
index 32c1f6d6..a0d41dfb 100644
--- a/python/parse_emails.py
+++ b/python/parse_emails.py
@@ -299,9 +299,8 @@ subject_nomura = re.compile("(?:Fwd:)?CDX (IG|HY)(\d{2}).*- REF:[^\d]*([\d.]+)")
subject_gs = re.compile("GS (IG|HY)(\d{2}) 5y.*- Ref [^\d]*([\d.]+)")
subject_sg = re.compile("SG OPTIONS - CDX (IG|HY) S(\d{2}).* REF[^\d]*([\d.]+)")
-def parse_email(email):
+def parse_email(email, date_received):
with open(email.path, "rt") as fh:
- date_received = datetime.datetime.fromtimestamp(int(fh.readline())/1000)
subject = next(fh)
for source in ['BAML', 'MS', 'NOMURA', 'GS', 'SG']:
m = globals()['subject_'+source.lower()].match(subject)
@@ -385,11 +384,13 @@ if __name__=="__main__":
except FileNotFoundError:
already_uploaded = {}
for f in emails:
- if f.name in already_uploaded:
+ date_received, msg_id = f.name.split("_")
+ date_received = datetime.datetime.strptime(date_received, "%Y-%m-%d %H-%M-%S")
+ if msg_id in already_uploaded:
continue
else:
try:
- key, (option_stack, fwd_index) = parse_email(f)
+ key, (option_stack, fwd_index) = parse_email(f, date_received)
except RuntimeError as e:
logging.error(e)
else: