From ee3bd28711fbd3802d555f8df3063b33fbf1b3c0 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 16 Apr 2025 10:32:50 -1000 Subject: [PATCH] ;doc:csv: How CSV rules are evaluated: clarify --- hledger/hledger.m4.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hledger/hledger.m4.md b/hledger/hledger.m4.md index fbe515556..0002fb311 100644 --- a/hledger/hledger.m4.md +++ b/hledger/hledger.m4.md @@ -4251,13 +4251,13 @@ if something 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). 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. 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. 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. 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.): - - Collect all assignments to this field, whether - top level assignments made by the `fields` rule, - top level direct assignments, - or conditional assignments made inside succeeding `if` blocks. - The last/bottom-most assignment wins. - - - Compute the field's actual value, - by interpolating any %CSVFIELD references within the assigned value, - or by choosing a default value if there was no assignment. + - Collect all assignments to this field, whether + top level assignments made by the `fields` rule, + top level direct assignments, + or conditional assignments made inside succeeding `if` blocks. + The last/bottom-most assignment wins. + + - Compute the field's actual value, + by interpolating any %CSVFIELD references within the assigned value, + or by choosing a default value if there was no assignment. c. Generate a hledger transaction (journal entry), from all the hledger field values.