summaryrefslogtreecommitdiff
path: root/bin/mycsv2ledger
blob: f59e3e3db3eb71af49ff2d85db40e94826821270 (plain)
  1. #!/bin/sh
  2. set -e
  3. infile="$1"
  4. dirname=$(dirname "$infile")
  5. basename=$(basename "$infile" .csv)
  6. outfile="${2:-$dirname/$basename.ledger}"
  7. rulesfile="$dirname/$basename.rules"
  8. {
  9. find * -wholename "$infile.rules" -execdir cat '{}' +;
  10. find * -wholename "$basename.*.rules" \! -name "$infile.rules" -execdir cat '{}' +;
  11. } > "$rulesfile"
  12. hledger print --rules-file "$rulesfile" -f "$infile" > "$outfile"
  13. rm "$rulesfile"