diff options
author | Jonas Smedegaard <dr@jones.dk> | 2014-09-05 14:37:20 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2014-09-05 14:37:20 +0200 |
commit | dbbd076cf9bfa1c337cefd757bc636f808b0bda6 (patch) | |
tree | 995d70a7081b7cde5966003347cc615eabf467f9 /bin | |
parent | da5727968ab7cd6c3e9068a7f0477bbc2141fc1a (diff) |
Split CSV parsing into scripts mycsv2ledger mymerkur2csv.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/mycsv2ledger | 12 | ||||
-rwxr-xr-x | bin/mymerkur2csv | 8 | ||||
-rwxr-xr-x | bin/mymerkur2ledger | 7 |
3 files changed, 20 insertions, 7 deletions
diff --git a/bin/mycsv2ledger b/bin/mycsv2ledger new file mode 100755 index 0000000..b13e1b7 --- /dev/null +++ b/bin/mycsv2ledger @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +infile="$1" +basename=$(basename "$infile" .csv) +outfile="${2:-$basename.ledger}" +rulesfile="$basename.rules" + +cat "$basename".*.rules > "$rulesfile" +hledger print --rules-file "$rulesfile" -f "$infile" > "$outfile" +[ "-d" = "$2" ] || rm "$rulesfile" diff --git a/bin/mymerkur2csv b/bin/mymerkur2csv new file mode 100755 index 0000000..e4ffef4 --- /dev/null +++ b/bin/mymerkur2csv @@ -0,0 +1,8 @@ +#!/bin/sh + +set -e + +infile="$1" +outfile="${2:-$(basename "$infile" .csv)_out.csv}" + +csvtool -t ";" -u COMMA square "$infile" > "$outfile" diff --git a/bin/mymerkur2ledger b/bin/mymerkur2ledger deleted file mode 100755 index e047935..0000000 --- a/bin/mymerkur2ledger +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -rulesfile="$1" -shift - -csvtool -t ";" -u COMMA square "$@" \ - | hledger print ${rulesfile:+--rules-file "$rulesfile"} -f- |