Skip to content

Commit 3b08f3e

Browse files
committed
;doc:csv:source: add data command examples
1 parent 1251dfb commit 3b08f3e

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

hledger/hledger.m4.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3321,9 +3321,27 @@ If hledger's CSV rules aren't enough, you can pre-process the downloaded data he
33213321
The command will be executed by your default shell, in the directory of the rules file, will receive the data file's content as standard input,
33223322
and should output zero or more lines of character-separated-values, suitable for conversion by the CSV rules.
33233323

3324+
Examples:
3325+
```
3326+
source ./paypal.json | paypalcsv
3327+
source data/simplefin.json | simplefincsv - 'chase.*card'
3328+
source OfxDownload*.csv | grep -vE '^(([^,]*,){6}[^,]*|)$' | sort -t, -n +2
3329+
source History_for_Account_Z20144832*.csv # | grep -E '^([^,]*,){12}[^,]*$' | sed -E -e 's/^ //' -e 's/\.([0-9]),/.\10,/g' -e 's/,([0-9]+),/,\1.00,/g'
3330+
```
3331+
33243332
Or, after `source` you can write `|` and a data generating command (with no file pattern before the `|`).
33253333
This command receives no input, and should output zero or more lines of character-separated values, suitable for conversion by the CSV rules.
33263334

3335+
Examples:
3336+
```
3337+
source | paypaljson | paypalcsv
3338+
source | paypalcsv data/paypal.json
3339+
source | simplefinjson >data/simplefin.json && simplefincsv data/simplefin.json 'chase.*card'
3340+
source | simplefincsv data/simplefin.json 'unify.*checking'
3341+
```
3342+
3343+
(`paypal*` and `simplefin*` scripts are in [bin/](https://github.com/simonmichael/hledger/tree/master/bin#readme))
3344+
33273345
Whenever hledger runs one of these commands, it will print the command on stderr.
33283346
If the command produces error output, but exits successfully, hledger will show the error output as a warning.
33293347
If the command fails, hledger will fail and show the error output in the error message.

0 commit comments

Comments
 (0)