balance format

13 views
Skip to first unread message

david whiting

unread,
Oct 17, 2025, 11:31:56 AM (9 days ago) Oct 17
to Ledger
Hi,

I'm trying to change the format of the balance output and am struggling to do it.
Using the default settings, I get something like:

   GBP -532,184.26  Income:Stuff
      GBP -13,259.50    Widgets
     GBP -223,450.08    Sprockets
       GBP -4,374.41    Other
--------------------
     GBP -532,184.26

I want to be able to remove the comma thousands separator and put a tab between the commodity and value and between the value and the accounts, e.g.:

   GBP\t-532,184.26\tIncome:Stuff

I want to do this because I'm working on automating pivot tables that will have the account names as rows and time periods as columns, with amounts in the cells. I have it working already with a bash script that manipulates the ledger output (using sed to insert tabs and remove the commas) and an awk script that creates the pivot table, but the bash script is a bit of a hack and I think it would be cleaner if I can use --balance-format to insert the tabs and remove the commas from the amounts.

The manual says that the default --balance-format is 

"%(justify(scrub(display_total), 20, -1, true, color))"
"  %(!options.flat ? depth_spacer : \"\")"
"%-(ansify_if(partial_account(options.flat), blue if color))\n%/"
"%$1\n%/"
"--------------------\n"

but I've been unable to use that explicitly using --balance-format and have been unable to get anything from my attempts to specify a --balance-format. 

Is it possible to do what I want to do?

Thanks.

David
--
David Whiting

Dimitar Dimitrov

unread,
Oct 17, 2025, 12:21:19 PM (9 days ago) Oct 17
to Ledger
I guess there are many variations, but how about this: `ledger bal -F "%(commodity(display_total))\t%(quantity(display_total))\t%(account)\n"`

Dimitar

david whiting

unread,
Oct 17, 2025, 1:49:07 PM (9 days ago) Oct 17
to ledge...@googlegroups.com
Yes, that does it - thank you!

David

--

---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ledger-cli/e4439f91-25a5-4ad6-bbd0-c15a3a761bf9n%40googlegroups.com.


--
David Whiting
Reply all
Reply to author
Forward
0 new messages