How to display the output with 3-digit comma separators and double hundredths (even if .00)?

67 views
Skip to first unread message

Keith David Bershatsky

unread,
Dec 1, 2020, 9:50:02 PM12/1/20
to Ledger
How can I instruct ledger-cli to display the output with three-digit comma separators and also double hundredths (even if .00)?

E.g., Instead of 1800, I would like to see 1,800.00

Thanks,

Keith

Kent R. Spillner

unread,
Dec 1, 2020, 10:32:56 PM12/1/20
to ledge...@googlegroups.com
That’s clearly documented in both the online docs & the webpage: ledger will automatically copy whatever format you use (e.g.: https://www.ledger-cli.org/3.0/doc/ledger3.html#Keeping-a-Journal).  So if you want it to format as $1,800.00 you just need to use that format in your ledger file(s).

Just this past weekend I noticed that I suddenly started getting 3 decimal places in my reports.  Turned out I had an errant $500.000 in one posting.

Sent from my iPhone

On Dec 1, 2020, at 20:50, Keith David Bershatsky <keith.david...@gmail.com> wrote:

How can I instruct ledger-cli to display the output with three-digit comma separators and also double hundredths (even if .00)?


E.g., Instead of 1800, I would like to see 1,800.00

Thanks,

Keith

--

---
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 on the web visit https://groups.google.com/d/msgid/ledger-cli/df6129d5-c7a9-4afe-8860-2d87a717b6dfn%40googlegroups.com.

Keith David Bershatsky

unread,
Dec 1, 2020, 11:16:51 PM12/1/20
to Ledger
Thank you, Kent, for having a look at this particular thread.  Unfortunately, the current version of ledger does not do this out-of-the-box.  All of my entries in the master ledger.dat file have commas as three-digit separators, and all hundredths are completely spelled out; e.g., 1,800.00; 13,750.50, etc. in the master ledger.dat file.

The reg and bal ledger reports all omit the 3-digit comma separators, and also omit the hundredths place when the number looks like 1800.5, and also omits both the tenths and hundredths place when the number looks like 1800.

Martin Michlmayr

unread,
Dec 2, 2020, 12:16:57 AM12/2/20
to ledge...@googlegroups.com
Add a $ sign or USD to the amount, You shouldn't use amounts without
commodities.

Adding $/USD should fix the display issue you see (I believe).


* Keith David Bershatsky <keith.david...@gmail.com> [2020-12-01 20:16]:
> > <https://groups.google.com/d/msgid/ledger-cli/df6129d5-c7a9-4afe-8860-2d87a717b6dfn%40googlegroups.com?utm_medium=email&utm_source=footer>
> > .
> >
> >
>
> --
>
> ---
> 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 on the web visit https://groups.google.com/d/msgid/ledger-cli/f1727df7-c2c9-49a6-8828-b44e3585d0fbn%40googlegroups.com.


--
Martin Michlmayr
https://www.cyrius.com/

Martin Michlmayr

unread,
Dec 2, 2020, 12:18:26 AM12/2/20
to ledge...@googlegroups.com
You can specify

D $1,000.00

but as Kent said ledger will figure it out automatically. (I think
the reason it doesn't is because you didn't specify a currency
symbol.)

* Keith David Bershatsky <keith.david...@gmail.com> [2020-12-01 18:50]:
> --
>
> ---
> 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 on the web visit https://groups.google.com/d/msgid/ledger-cli/df6129d5-c7a9-4afe-8860-2d87a717b6dfn%40googlegroups.com.

Kent R. Spillner

unread,
Dec 2, 2020, 1:03:29 AM12/2/20
to ledge...@googlegroups.com
Are you absolutely certain?  What version of ledger do you have installed?  Which operating system are you using?  How did you install ledger (i.e. from official packages for your system, or did you build it yourself from source)?  What is the exact command you are running?  Can you share a minimal snippet of your ledger file that reproduces the issue (anonymize the accounts & change the actual values, etc.)?  Can you reproduce it with a new minimal ledger file?

For example, what is the output if you run the something like the following commands (‘$’ represents your command prompt):

$ ledger —version
$ cat >foo.dat <<EOF
2020-12-01 * (1234) Acme, Inc.
    expenses:misc   \$1,234,567,890.95
    assets:checking
EOF
$ ledger -f foo.dat balance

Sent from my iPhone

On Dec 1, 2020, at 22:16, Keith David Bershatsky <keith.david...@gmail.com> wrote:

Thank you, Kent, for having a look at this particular thread.  Unfortunately, the current version of ledger does not do this out-of-the-box.  All of my entries in the master ledger.dat file have commas as three-digit separators, and all hundredths are completely spelled out; e.g., 1,800.00; 13,750.50, etc. in the master ledger.dat file.

Keith David Bershatsky

unread,
Dec 2, 2020, 1:48:56 AM12/2/20
to Ledger
Thank both, Kent and Martin:  You are both correct ... adding a dollar sign corrects the issue.  I was looking for a command-line argument or a master setting of some type that would affect reports for the entire file of about 41,000 lines of entries.  I have since done a search/replace of all numbers by adding a dollar sign, and I can confirm that this works now.

Stack Overflow

unread,
Dec 22, 2020, 3:54:39 PM12/22/20
to Ledger
I opted not to use the dollar sign throughout my 41,000 lines of entries (even though I could have done a search and replace).  Instead, I found the following workaround:  --amount '($1,000.00*a)/$1,000.00'

Prior to that workaround (supra), I used a function in Emacs to replace-regexp-in-string, but that prior workaround is now deprecated by the above-mentioned approach.

Reply all
Reply to author
Forward
0 new messages