Skip to content

Instantly share code, notes, and snippets.

@jiaaro
Last active April 27, 2021 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jiaaro/53a5631cae043c8bd425581a9e98c47b to your computer and use it in GitHub Desktop.
Save jiaaro/53a5631cae043c8bd425581a9e98c47b to your computer and use it in GitHub Desktop.
Coinbase Export: Parse and Process "Convert" Transactions
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