-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheth.py
More file actions
19 lines (17 loc) · 881 Bytes
/
eth.py
File metadata and controls
19 lines (17 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import csv
import datetime
if __name__ == '__main__':
eth = open("input/eth-in", "r")
output_lines = []
for line in eth.readlines():
print(line)
timestamp, tradeType, amount, currency, size_usd, fee = line.split(',')
timestamp2 = datetime.datetime.strptime(timestamp, "%m-%d-%YT%H:%M:%S").strftime("%Y-%m-%dT%H:%M:%S")
if tradeType == 'Buy':
output_lines.append([timestamp2, tradeType, amount, currency, size_usd, 'USD', float(fee), 'USD', 'ETH', 'US'])
elif tradeType == 'Sell':
output_lines.append([timestamp2, tradeType, size_usd, 'USD', amount, currency, float(fee), 'USD', 'ETH', 'US'])
with open('eth-trades.csv', mode='w') as output:
output = csv.writer(output, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
for txn in output_lines:
output.writerow(txn)