summaryrefslogtreecommitdiff
path: root/bin/mycsv2ledger
diff options
context:
space:
mode:
Diffstat (limited to 'bin/mycsv2ledger')
-rwxr-xr-xbin/mycsv2ledger12
1 files changed, 12 insertions, 0 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"