Interpret $ as USD

6 views
Skip to first unread message

Nicholas McAvoy

unread,
Nov 14, 2024, 12:32:28 PMNov 14
to hledger
Hi,

I apologize if this answer is readily available; I tried looking through docs and also asking an LLM first.

In my ledger, I use USD (as a suffix) to refer to US dollars. I'm importing a CSV file that uses dollar signs (as a prefix). How can I configure hledger to take $input as output USD?

Thanks!
Nick McAvoy

p.s. I love hledger.

Nicholas McAvoy

unread,
Nov 14, 2024, 12:53:33 PMNov 14
to hledger
I've sort of got a workaround here: I've got a price directive `P 2024/01/01 $ 1.00 USD`, and when running e.g. income statement, the `--value=now` flag gives the output in USD.

This works, but I guess I'm wondering more specifically if hledger can write the transactions it $imports into the ledger with a USD suffix, eliminating the need for my workaround.

Thanks again!

Simon Michael

unread,
Nov 14, 2024, 1:19:40 PMNov 14
to hle...@googlegroups.com
Hi Nicholas,

On Thu, Nov 14, 2024, at 07:53, Nicholas McAvoy wrote:
I've sort of got a workaround here: I've got a price directive `P 2024/01/01 $ 1.00 USD`, and when running e.g. income statement, the `--value=now` flag gives the output in USD.

That's a good hack, but adds some noise of course.

CSV rules, and hledger generally, can add a currency/commodity, but can't rewrite existing ones, currently.

So if one of your CSV fields provides just the number without the symbol, you can use that, and then add your currency code with a `currency` (or `currencyN`) CSV rule. If not, I think you'll have to preprocess the CSV with sed.


This works, but I guess I'm wondering more specifically if hledger can write the transactions it $imports into the ledger with a USD suffix, eliminating the need for my workaround.

Thanks again!
On Thursday, November 14, 2024 at 12:32:28 PM UTC-5 Nicholas McAvoy wrote:
Hi,

I apologize if this answer is readily available; I tried looking through docs and also asking an LLM first.

In my ledger, I use USD (as a suffix) to refer to US dollars. I'm importing a CSV file that uses dollar signs (as a prefix). How can I configure hledger to take $input as output USD?

Thanks!
Nick McAvoy

p.s. I love hledger.


--
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.

Reply all
Reply to author
Forward
0 new messages