git ssb

0+

cel / ledger-scripts



Tree: f1521af2d73e96acaa4e96dfc60dbfc50373845a

Files: f1521af2d73e96acaa4e96dfc60dbfc50373845a / blockchain2ledger

731 bytesRaw
1#!/usr/bin/awk -f
2#
3# blockchain2ledger
4# Parse CSV from blockchain.info into ledger format
5
6BEGIN {
7 FS=",";
8 assets_account="Assets:Bitcoin:Blockchain.info";
9}
10
11# Skip header
12/^date/ {
13 next;
14}
15
16# Read transaction
17{
18 date = $1;
19 description=$2;
20 money_in=+$3;
21 money_out=+$4;
22 tx=$5;
23
24 i = index(date, " ")-1;
25 date = substr(date, 1, i);
26 gsub("-", "/", date);
27
28 value = money_in - money_out;
29 account = money_in ? "Income" : "Expenses";
30 description = substr(description, 1, 1) tolower(substr(description, 2))
31
32 printf "; %s\n", tx;
33 printf "%s %s\n", date, description;
34 printf " %-32s %12.8f BTC\n", assets_account, value;
35 printf " %s\n", account;
36 print "";
37}
38

Built with git-ssb-web