summaryrefslogtreecommitdiff
path: root/bin/mycsv2ledger
blob: 8bdf3a2f9b2655a640cf0be4f6b9f0cb43c2d669 (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. cat << EOF > "$outfile"
  9. D 1,000.00 DKK
  10. EOF
  11. {
  12. find * -wholename "$infile.rules" -execdir cat '{}' +;
  13. find * -wholename "$basename.*.rules" \! -name "$infile.rules" -execdir cat '{}' +;
  14. } > "$rulesfile"
  15. hledger print --rules-file "$rulesfile" -f "$infile" >> "$outfile"
  16. rm "$rulesfile"