;doc:csv: CSV fields and hledger fields: edits
This commit is contained in:
parent
19efd392b9
commit
c0ec0f4381
@ -3677,28 +3677,33 @@ you should declare the decimal mark explicitly with this rule, to avoid misparse
|
||||
|
||||
## CSV fields and hledger fields
|
||||
|
||||
This can be confusing, so here's an overview. (It mentions some things we haven't covered yet.)
|
||||
This can be confusing, so let's start with an overview:
|
||||
|
||||
- **CSV fields** are provided by your data file.
|
||||
Their default name is their position in the CSV record, starting with 1.
|
||||
You can also give them a readable name (with the `fields` rule).
|
||||
They are named by their position in the CSV record, starting with 1.
|
||||
You can also give them a readable name.
|
||||
|
||||
- **hledger fields** are predefined.
|
||||
They correspond to parts of a transaction's journal entry (mostly).
|
||||
`date`, `description`, `account1`, `amount1`, `account2` are some of these.
|
||||
- **hledger fields** are predefined;
|
||||
`date`, `description`, `account1`, `amount1`, `account2` are some of them.
|
||||
They correspond to parts of a transaction's journal entry, mostly.
|
||||
|
||||
- These are the only fields you'll work with; you can't make new ones in a rules file.
|
||||
(If you need extra CSV fields, you can add them to the data in preprocessing, before running the rules.)
|
||||
- The CSV fields and hledger fields are the only fields you'll be working with;
|
||||
you can't define new fields, or variables as in a programming language.
|
||||
(But you could add extra CSV fields to the data in preprocessing, before running the rules.)
|
||||
|
||||
- You'll be reading CSV fields. (They can't be written to.) They'll be on the right hand side, with a % prefix. Eg
|
||||
- For each CSV record, you'll assign values to one or more of the hledger fields to build up a transaction (journal entry).
|
||||
Values can be static text, CSV field values from the current record, or a combination of these.
|
||||
|
||||
- For simple cases, you can give a CSV field the same name as one of the hledger fields,
|
||||
then its value will be automatically assigned to that hledger field.
|
||||
|
||||
- CSV fields can only be read, not written to. They'll be on the right hand side, with a % prefix. Eg
|
||||
- testing a CSV field's value: `if %CSVFIELD ...`
|
||||
- interpolating its value: `HLEDGERFIELD %CSVFIELD`
|
||||
|
||||
- You'll be writing to hledger fields. (They can't be read.) They'll be on the left hand side, with no prefix. Eg
|
||||
- setting the transaction's description: `description VALUE`
|
||||
|
||||
- You can give a CSV field the same name as one of the hledger fields.
|
||||
If you do, its value will be automatically assigned to that hledger field.
|
||||
- hledger fields can only be written to, not read. They'll be on the left hand side (or in a fields list), with no prefix. Eg
|
||||
- setting the transaction's description to a value: `description VALUE`
|
||||
- setting the transaction's description to the second CSV field's value `fields date, description, ...`
|
||||
|
||||
## `fields` list
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user