Last active
April 27, 2021 20:02
-
-
Save jiaaro/53a5631cae043c8bd425581a9e98c47b to your computer and use it in GitHub Desktop.
Coinbase Export: Parse and Process "Convert" Transactions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
csv_path = "/path/to/Coinbase-xxxxx-TransactionsHistoryReport-2021-03-13-22-28-28.csv" | |
outcsv_path = csv_path + ".processed.csv" | |
with open(csv_path, "r") as fi, open(outcsv_path, "w") as fo: | |
r = csv.reader(fi) | |
w = csv.writer(fo) | |
for i, row in enumerate(r): | |
if row and row[-1].startswith("Converted"): | |
note = row[-1] | |
to_coin = note.split(" ")[-1] | |
to_coin_qty = note.split(" ")[-2] | |
row += [to_coin, to_coin_qty] | |
w.writerow(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment