Customized register output

19 views
Skip to first unread message

Jasel17212

unread,
Feb 4, 2023, 7:41:54 PM2/4/23
to hledger
How can I list items in a register format that have a check number (code) and sorted by check number?

Here's how I accomplish that in ledger-cli

l reg ^Exp and expr 'code and int(code) > 100' --format "%-5(code) %-11(date) %-40(payee) %50(amount)\n" --sort code

Output

3082  2021/11/02  xx     $2,625.00
3083  2021/11/23  xx       $500.00
3084  2021/11/10  xx     $2,500.00
3085  2021/12/08  xx       $500.00
3086  2021/12/09  xx       $508.65

Thanks
JL

Simon Michael

unread,
Feb 4, 2023, 8:25:01 PM2/4/23
to hledger
The query would be something like (using a regexp to test for > 100):

$ hledger reg ^exp code:'[1-9]..' 

But, hledger register does not show code by default, and does not yet have the --format option (only balance does). 

All is not lost however, as code is included in CSV output. So you could get it with

$ hledger reg ^exp code:'[1-9]..' -O csv | SOMETHING

I got it working with dsq (https://hledger.org/dsq.html):

$ hledger reg ^exp code:'[1-9]..' -O csv | dsq -s csv -n -p  "select * from {} order by code desc"

Jasel17212

unread,
Feb 4, 2023, 9:47:56 PM2/4/23
to hledger
Perfect ... thanks Simon!
Reply all
Reply to author
Forward
0 new messages