Customizable fields in hledger register txt output

16 views
Skip to first unread message

avilla...@gmail.com

unread,
Jun 7, 2022, 9:49:55 AMJun 7
to hledger
Hi -

I am wondering whether it is possible to customize the register command to show specific fields.

There are three fields I am particularly interested in: a reference to the entry generating the register line (e.g., something in the form of filename:LINE_NUMBER) and the ID and reconciliation status of the transaction.

This would speed up reconciliation of entries... well, in my workflow, at least! :-) In fact, I use the ID to group all entries appearing in a given paper statement, the reconciliation for expected transactions not yet happened (e.g. the phone bills for the year). The reference to the file would allow to quickly jump to the originating entry, when the input is not gotten via a pipe.

If it is not possible to change the default register format, would it make sense to add a command line option to chooses which fields to show?

... and, of course, my sincere appreciation for all the work and effort put on hledger!

thanks
- adolfo villafiorita



Simon Michael

unread,
Jun 10, 2022, 1:43:46 AMJun 10
to hle...@googlegroups.com
Hi, just a top of the head answer - does `hledger print -O csv` help ?

On Jun 7, 2022, at 14:49, avilla...@gmail.com <avilla...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "hledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hledger+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hledger/b590a2f9-12d6-43a8-bd18-aab621be9191n%40googlegroups.com.

avilla...@gmail.com

unread,
Jun 10, 2022, 3:48:27 PMJun 10
to hledger
Hi, 
thanks for the suggestion. It helps quite a bit, but there are still a couple of loose ends.

I can pipe the output of hledger to miller (mlr) and get something like:

hledger register bank -O csv | mlr --icsv --opprint --barred cut -f txnidx,date,code,account,amount,total
+--------+------------+--------------------------+---------------------+------------+------------+
| txnidx | date       | code                     | account             | amount     | total      |
+--------+------------+--------------------------+---------------------+------------+------------+
| 1      | 2022-01-01 |                          | assets:bank         | € 1000.00  | € 1000.00  |
| 96     | 2022-02-01 |                          | assets:bank         | € -100.00  | € 900.00   |

The loose ends:
  • the reconciliation status is not output in CSV format - do I get it right?
  • I am not sure how to link txnidx to its position in the source file (e.g. txnidx 96 is at line 230 of file bank.hledger)
Being able to output the code, however, is a big improvement!

  thanks
  -a

Simon Michael

unread,
Jun 10, 2022, 3:55:37 PMJun 10
to hledger

On Jun 10, 2022, at 20:48, avilla...@gmail.com <avilla...@gmail.com> wrote:

I can pipe the output of hledger to miller (mlr) and get something like:

hledger register bank -O csv | mlr --icsv --opprint --barred cut -f txnidx,date,code,account,amount,total
+--------+------------+--------------------------+---------------------+------------+------------+
| txnidx | date       | code                     | account             | amount     | total      |
+--------+------------+--------------------------+---------------------+------------+------------+
| 1      | 2022-01-01 |                          | assets:bank         | € 1000.00  | € 1000.00  |
| 96     | 2022-02-01 |                          | assets:bank         | € -100.00  | € 900.00   |

The loose ends:
  • the reconciliation status is not output in CSV format - do I get it right?
You're right.. it's included in print's CSV output, but not in register's.

  • I am not sure how to link txnidx to its position in the source file (e.g. txnidx 96 is at line 230 of file bank.hledger)
None of our commands report this information, except for https://github.com/simonmichael/hledger/blob/master/bin/hledger-print-location.hs which demonstrates how it could be obtained. I think you would need a haskell script of this kind to make this custom report, then you can show whatever you want.
Reply all
Reply to author
Forward
0 new messages