blob: 9b3935e51e26a9c82c7929861a1a4534083cbd2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
from serenitas.utils.env import DAILY_DIR
from serenitas.utils.exchange import ExchangeMessage
import os
import pandas as pd
from datetime import date
import io
em = ExchangeMessage()
emails = em.get_msgs(path=["NYops", "FXgo"], count=5, subject__contains="Notification")
unmodified_files = []
for msg in emails:
for attach in msg.attachments:
dest = DAILY_DIR / "fxgo" / attach.name
dest.write_bytes(attach.content)
output = io.StringIO()
with open(dest, "r") as f:
for line in f.readlines()[4:]:
if "BEGIN PGP SIGNATURE" in line:
break
else:
output.write(line)
output.seek(0)
df = pd.read_csv(output)
cp, msgtype, date, time = df[
["Bank1DealingCode", "MsgType", "DateOfDeal", "TimeOfDeal"]
].loc[0]
df.to_csv(DAILY_DIR / "fxgo" / f"{date}_{cp}_{msgtype}_{time}.csv", index=False)
os.remove(dest)
|