;doc: csv: amount decimal places: edits

This commit is contained in:
Simon Michael 2024-04-24 14:13:22 -10:00
parent 7f72cce6ce
commit 876f115806

View File

@ -3837,16 +3837,19 @@ that would trigger the prepending effect, which we don't want here.
When you are reading CSV data, eg with a command like `hledger -f foo.csv print`, When you are reading CSV data, eg with a command like `hledger -f foo.csv print`,
hledger will infer each commodity's decimal precision (and other [commodity display styles](#commodity-display-styles)) hledger will infer each commodity's decimal precision (and other [commodity display styles](#commodity-display-styles))
from the amounts - much as when reading a journal file without `commodity` directives (see the link). from the amounts - much as when reading a journal file without `commodity` directives (see the link).
But note these commodity styles are not inferred from the numbers in the original CSV data;
Note these commodity styles are not inferred from the numbers in the original CSV data;
rather, they are inferred from the amounts generated by the CSV rules. rather, they are inferred from the amounts generated by the CSV rules.
When you are importing CSV data with the `import` command, eg `hledger import foo.csv`, When you are importing CSV data with the `import` command, eg `hledger import foo.csv`,
it's a little different: `import` [applies](#commodity-display-styles) the journal's existing commodity styles to the new entries. there's another step: `import` tries to make the new entries [conform](#commodity-display-styles) to the journal's existing styles.
So for each commodity, let's say for EUR, `import` will use: So for each commodity - let's say it's EUR - `import` will choose:
1. the style declared for EUR by a [`commodity` directive](#commodity-directive) in the journal 1. the style declared for EUR by [a `commodity` directive](#commodity-directive) in the journal
2. or if there's no such directive: the style inferred from EUR amounts in the journal 2. otherwise, the style inferred from EUR amounts in the journal
3. or if there are no EUR amounts in the journal: the style inferred from EUR amounts generated by the CSV rules. 3. otherwise, the style inferred from EUR amounts generated by the CSV rules.
TLDR: if `import` is not generating the precisions or styles you want, add a `commodity` directive specifying them.
### Referencing other fields ### Referencing other fields