;doc:csv: How CSV rules are evaluated: clarify
This commit is contained in:
parent
bcc8471966
commit
ee3bd28711
@ -4251,13 +4251,13 @@ if something
|
|||||||
|
|
||||||
Here's how to think of CSV rules being evaluated:
|
Here's how to think of CSV rules being evaluated:
|
||||||
|
|
||||||
1. All `include`d rules files are inlined, from top to bottom, depth first
|
1. Any `include`d rules files are inlined, from top to bottom, depth first
|
||||||
(scanning each included file for further includes recursively before proceeding).
|
(scanning each included file for further includes recursively before proceeding).
|
||||||
|
|
||||||
2. Top level rules (`date-format`, `fields`, `newest-first`, `skip` at top level, etc) are processed, top to bottom.
|
2. Top level rules (`date-format`, `fields`, `newest-first`, `skip` at top level, etc) are processed, top to bottom.
|
||||||
With most rules, if it is seen more than once, the last/bottom-most wins.
|
With most rules, if it is seen more than once, the last/bottom-most wins.
|
||||||
But with `skip`/`end` rules, the first/top-most wins.
|
But with `skip`/`end` rules, the first/top-most wins.
|
||||||
`skip [N]` immediately skips the current or the next N CSV records.
|
`skip [N]` immediately skips the current or next N CSV records.
|
||||||
`end` immediately skips all remaining CSV records.
|
`end` immediately skips all remaining CSV records.
|
||||||
|
|
||||||
3. For each CSV record in turn:
|
3. For each CSV record in turn:
|
||||||
@ -4265,18 +4265,18 @@ Here's how to think of CSV rules being evaluated:
|
|||||||
a. Search the `if` blocks, from top to bottom, for a succeeding one containing a `skip` or `end` rule.
|
a. Search the `if` blocks, from top to bottom, for a succeeding one containing a `skip` or `end` rule.
|
||||||
If found, immediately skip the specified number of CSV records.
|
If found, immediately skip the specified number of CSV records.
|
||||||
|
|
||||||
b. Otherwise, compute hledger field values.
|
b. Otherwise, compute hledger field values for this record.
|
||||||
For each hledger field (`date`, `description`, `account1`, etc.):
|
For each hledger field (`date`, `description`, `account1`, etc.):
|
||||||
|
|
||||||
- Collect all assignments to this field, whether
|
- Collect all assignments to this field, whether
|
||||||
top level assignments made by the `fields` rule,
|
top level assignments made by the `fields` rule,
|
||||||
top level direct assignments,
|
top level direct assignments,
|
||||||
or conditional assignments made inside succeeding `if` blocks.
|
or conditional assignments made inside succeeding `if` blocks.
|
||||||
The last/bottom-most assignment wins.
|
The last/bottom-most assignment wins.
|
||||||
|
|
||||||
- Compute the field's actual value,
|
- Compute the field's actual value,
|
||||||
by interpolating any %CSVFIELD references within the assigned value,
|
by interpolating any %CSVFIELD references within the assigned value,
|
||||||
or by choosing a default value if there was no assignment.
|
or by choosing a default value if there was no assignment.
|
||||||
|
|
||||||
c. Generate a hledger transaction (journal entry), from all the hledger field values.
|
c. Generate a hledger transaction (journal entry), from all the hledger field values.
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user