Created
September 5, 2019 23:49
-
-
Save adept/c3f9b9597ed3eb840bbadddf27f5793e to your computer and use it in GitHub Desktop.
hledger to sankey.csv
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
#!/bin/bash | |
( | |
echo "source,target,value"; | |
( | |
hledger -f 2018.journal is --cost -O csv -N --tree \ | |
| sed -nre 's/["£]//g; /expenses,/{s/^/income,/;p}; /expenses[^,]/{s/(.+):([^:]+),/\1,\1:\2,/;p}; /income[^,]/{s/(.+):([^:]+),/\1:\2,\1,/;p};' \ | |
| awk -vOFS=, -F, '$3>300 {print $1,$2,$3}' \ | |
| sort -rn -t, -k3 | |
) | |
) > sankey.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment