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