A column the file does not have is not a column of zeros
“An import brought in a whole bank statement at 0.00 a row, or zeroed only the withdrawals, and the app reported no error at all. The file opens fine in a spreadsheet and the amounts are plainly there, so I cannot tell whether the file is wrong, the mapping is wrong, or the importer is.”
Someone imports the October export from the same bank they import every month. The mapping is saved, so there is nothing to fill in. The import succeeds. Every line comes in at 0.00.
Nothing threw, nothing was logged, and no row was rejected. The bank had renamed one header.
That is the scenario in jwh3times/LeaseBook#645, a bank statement import in a property-management app, fixed the same day by PR #649.
One lookup, two questions
The code that does this is short enough to read in full. This is its CsvStatementParser at the
commit before the fix:
// The first column whose header is exactly the mapped name, or null when the header has none: a mapped
// column absent from the file reads like an empty field and is handled per row.
private static string? Field(CsvReader csv, string name)
{
for (var i = 0; i < csv.Headers.Count; i++)
{
if (string.Equals(csv.Headers[i], name, StringComparison.Ordinal))
{
return csv.GetString(i);
}
}
return null;
}
Field answers one question, "what is in this row's column called Amount", and when there is no
such column its answer is null. Then:
private static decimal ParseDecimal(string? raw)
{
var value = (raw ?? string.Empty).Trim();
if (value.Length == 0)
{
return 0m; // an empty money cell (e.g. the unused side of a debit/credit pair) is zero
}
...
That comment is the whole bug, and it is not a careless comment. It is right about the case it
names. In a statement with separate Withdrawal and Deposit columns, every row has one of them
filled and the other blank, and the blank one really does mean zero, because the row's amount is on
the other side.
It is also, for every other caller, a number nobody wrote down. (raw ?? string.Empty) is where an
absent column and an empty cell merge, and after that line the information needed to tell them apart
is gone. The zero is decided one cell at a time, by a function that cannot see the column map, the
header, or the rest of the row.
The same absence, loud in one column and silent in the next
Look at what the date path does with the identical condition:
private static DateOnly ParseDate(string? raw, string? explicitFormat)
{
var value = (raw ?? string.Empty).Trim();
if (value.Length == 0)
{
throw new FormatException("date is empty.");
}
A missing date column throws on every row, and those throws are caught and collected as per-row errors, so the user sees a file where nothing imported and every line carries a reason. A missing amount column imports cleanly at zero.
Nobody decided that dates matter more than money. The asymmetry falls out of a question that was never asked: an empty date has no plausible default, so the empty case had to raise, and an empty money cell has an obvious one, so it did not. Which absence gets reported depends on whether the field's type happens to have a convincing zero value.
Half right is harder to catch than all wrong
A statement mapped to a Debit and Credit pair makes this considerably harder to spot. Before the
fix, the signed amount was:
// Customer-account convention: credit increases the balance (+), debit decreases it (−).
var credit = map.Credit is null ? 0m : ParseDecimal(Field(csv, map.Credit));
var debit = map.Debit is null ? 0m : ParseDecimal(Field(csv, map.Debit));
return credit - debit;
map.Debit is null asks whether the user mapped a debit column, not whether the file has one. So if
the mapping names Withdrawal and the new export calls it something else, Field returns null,
ParseDecimal returns 0m, and the arithmetic becomes credit - 0.
Every deposit is correct. Every withdrawal is 0.00.
The resulting statement is not obviously broken. It has real dates, real descriptions, a plausible spread of values, and only money coming in. A screen full of zeros gets reported in minutes. A statement that is right about half its rows gets reconciled.
The zero does not stay in the amount column
This part is only visible by reading further. The same importer deduplicates against every previously imported line for the account, and the key is:
/// The re-import fingerprint (P67): a stable SHA-256 over <c>(statement_date, amount, normalized
/// description)</c>. ...
...
public static string Compute(DateOnly date, decimal amount, string description)
{
var canonical = string.Create(CultureInfo.InvariantCulture,
$"{date:yyyy-MM-dd}|{amount:0.00}|{Normalize(description)}");
The amount is part of the record's identity. Force it to a constant and two lines that differed only in amount become the same line.
Reconstructing that canonical string exactly as the source builds it, over three rows where two share a date and a description:
amount column present
2026-10-01|-1450.00|ACH PAYMENT RENT 4dc4997fcb97da59... stored
2026-10-03|980.50|DEPOSIT TENANT 4B 009a953e3311bff2... stored
2026-10-03|1200.00|DEPOSIT TENANT 4B 3a14fffd8038a3ba... stored
Imported=3 SkippedDuplicates=0 Errors=0
amount column missing, every amount 0.00
2026-10-01|0.00|ACH PAYMENT RENT 0854b0fe34758cab... stored
2026-10-03|0.00|DEPOSIT TENANT 4B 18b2e4cfab4ed1cc... stored
2026-10-03|0.00|DEPOSIT TENANT 4B 18b2e4cfab4ed1cc... SKIPPED as duplicate
Imported=2 SkippedDuplicates=1 Errors=0
Three rows in, two rows stored, one counted as a duplicate, no errors. That report is indistinguishable from a healthy re-import of a file you already had, which is the normal and expected outcome of this feature. The invented zero has stopped being a wrong value in a column and become a wrong answer to "have I seen this transaction before", and in that role it drops rows.
What three readers actually do
The reader is not where this gets decided, which is worth demonstrating rather than asserting. The
original report tabulated its parser against three wrong maps; here are the same three asked of
general-purpose readers. One file, header Date,Description,Amount, asked for a column named Amt,
a column named amount (right name, wrong case), and a column named Withdrawal:
| Reader | Call | Result for a column the file lacks |
|---|---|---|
csv.DictReader (CPython 3.13.18) |
row[name] |
raises KeyError: 'Amt' |
csv.DictReader |
row.get(name) |
None, every row, no error |
| pandas 3.0.5 | read_csv(usecols=[...]) |
raises ValueError: Usecols do not match columns, columns expected but not found: ['Amt'] |
| pandas 3.0.5 | df[name] |
raises KeyError: 'Amt' |
| pandas 3.0.5 | df.reindex(columns=[name]) |
NaN, every row, no error |
| Papa Parse 5.7.1 | row[name] after header: true |
undefined, every row; results.errors is [] |
Two things come out of that table.
The first is that most of these libraries offer both a loud answer and a quiet one, and the quiet one
is shorter to type. row.get(name) and df.reindex are the defensive-looking spellings, chosen
precisely so the code will not crash on a file with a surprise in it, and what they buy is that it
does not crash while being wrong. JavaScript is the sharpest version: Number(undefined) is NaN,
so Papa Parse's undefined would at least poison the arithmetic visibly, until someone writes the
guard everyone writes. Number(row[name] || 0) turns the absent column into zero, and Number("")
is 0 as well, so that guard cannot tell the two apart either.
The second is structural. A CSV reader checks the file against itself. Papa Parse does this
carefully: it counts each row's fields against the header and reports TooFewFields and
TooManyFields, and its field list is, per its own source, "from the header row of the input, if
there is one". CPython documents the same shape of check, that when "a non-blank row has fewer fields
than fieldnames, the missing values are filled-in with the value of restval (which defaults to
None)". Both are comparisons between the rows and the header of one file. Neither can tell you the
header is missing a column, because neither was ever told which columns you needed.
Exactly one call in that table was told. usecols is a declaration of the columns the caller
expects, and because pandas holds that list it can do the comparison. The implementation is the whole
of it:
missing = [c for c in usecols if c not in names]
if len(missing) > 0:
raise ValueError(
f"Usecols do not match columns, columns expected but not found: "
f"{missing}"
)
Its docstring says it plainly: "Validates that all usecols are present in a given list of names. If not, raise a ValueError that shows what usecols are missing." This is not difficult code. It is a decision about where the expectation lives, and a column map is an expectation, written down, sitting in your database.
Where the check goes
The fix in that app puts it before anything else. The parser gains a pass that runs after the header is read and before the first data row:
var missing = MissingColumns(csv, map);
if (missing.Count > 0)
{
return new ParsedStatement(rows, errors, missing);
}
MissingColumns is the same set difference as the pandas one, over the five mapped fields, returning
a MissingColumn(Field, Name) for each: the map property that was wrong, and the header name it
named. The handler turns each into one validation failure keyed like the rest, with the message "The
file has no column named '{name}'. Check the column mapping against the file's header row." The
project's architecture note records the scope deliberately:
The one file-level refusal is a column map that names a column the header row lacks: the import is refused with a 400 naming each absent column, before any row is read or stored. Headers match the map case-sensitively, ignoring surrounding spaces. An absent column used to read as an empty field, so a missing amount column imported every row at 0.00 with no error.
Four properties of that are worth separating, because each one is a choice.
It is a whole-file refusal in a parser whose every other failure is per-row. A bad date is one reported row out of nine hundred. A map that does not fit the file is not a property of any row, so reporting it per row would produce nine hundred copies of one fact, and importing the good rows anyway would mean storing the fabricated zeros. The tests pin both halves: given a map naming an absent column, the missing-column list holds exactly that column, and the rows and the row-errors are both empty.
It names every absent column, not the first. Someone whose mapping was built against last year's export usually has more than one name wrong, and a check that stops at the first makes them run the import once per mistake.
Case counts; surrounding spaces do not. A header of amount against a map of Amount is
reported as missing, which is the right call given that the lookup is exact: silently matching it
would mean the refusal and the reader disagree about what exists. Spaces are trimmed on both sides
because the import wizard offers header names trimmed, so a file written as Date, Description, Amount maps as Amount. Both behaviours have their own test.
A blank mapped name now means unmapped. "amount": "" beside a debit and credit pair used to be
non-null, so it counted as mapped, and Field dutifully looked for a column named empty string and
returned null. The fix replaces the null checks with a whitespace check, closing a second route
into the same zero.
The same absence, one row at a time
The file-level check left one path open, and the same project found it within the hour.
LeaseBook#650 is a row shorter than its header:
2026-02-01,Rent under Date,Description,Amount. The missing trailing field reads as empty, the
empty amount reads as zero, and the row imports at 0.00 with no error. The header has the column;
this row does not.
The report is careful about why that is not a one-line fix. A debit and credit export that leaves off
the empty trailing credit on a withdrawal is probably a normal bank file, and that short row does have
an amount. So the fix, two days later, moved the zero up a level. ParseDecimal now returns no value
for an empty field instead of zero, and the zero is supplied only where the row can justify it:
var credit = IsMapped(map.Credit) ? ParseDecimal(Field(csv, map.Credit!)) : null;
var debit = IsMapped(map.Debit) ? ParseDecimal(Field(csv, map.Debit!)) : null;
return credit is null && debit is null ? null : (credit ?? 0m) - (debit ?? 0m);
One side of a pair missing is a zero, because the other side is the amount. Both missing, or a single
Amount with nothing in it, is a row error: "amount is empty." A stated 0.00 still imports as
zero. The empty cell that the first version called zero turned out to be the same question as the
missing column, asked of a smaller piece of the file.
Absent, empty and zero are three states
A developer on an unrelated logistics importer wrote the rule down as an invariant for their own
codebase: "an absent Excel column is 'no information', not 'set to empty/zero'". Their report,
ANSER-Logistics/ANSER-logistics-body#9,
still open as this is written, is the same mechanism one step further on. A missing stock column produced stock: 0,
which did not merely display wrongly but wrote an adjustment row to the ledger, because zero was
treated as a figure the file had supplied.
That is the general shape. A default converts an absence into a value, the value is as real as any other from then on, and it propagates into dedupe keys, adjustments, balances and reports with nothing marking it as invented. The place to refuse is the one point where the two states are still distinguishable, which is before the first row is read, while you still have the file's header in one hand and the list of columns you wanted in the other.
Where TableRune fits
TableRune imports CSV, Parquet and spreadsheets with no column map at all. A spreadsheet sheet is
converted to CSV first, and CSV goes through DuckDB's read_csv_auto, so the columns are whatever
the file declares, and the operation forms are populated
from the columns the loaded file actually has. There is no mapping step that can disagree with a
file, which removes this failure from the import path rather than solving it.
It returns in the one place it can: a saved workflow reloaded onto a different file. The code that
handles that names the case first, in its header comment, as "a step references a column the current
data doesn't have (typically a saved workflow reloaded onto a file with a different header)". Because
every operation lowers to SQL over the file's own inferred schema, an absent column is a bind error
from DuckDB rather than a lookup that returns a default: there is no Field to hand back an empty
value. What the app adds is attribution, turning the binder error into the step number and the
column, "Step 3 (Sort) uses a column named "region", which this data doesn't have. The step may have
been saved against a file with a different header", and separating that from the other cause of the
same binder error, an unquoted text value in a formula.
The dedupe comparison is the one worth stating, since that is the failure above that loses data.
Remove duplicates lowers to a SELECT DISTINCT over *, per the comment in the pipeline builder
"over every column present now (not the stored list)". The key is therefore built only from values
the file supplied, so it cannot collapse two rows on a default that no column provided. A fixed key
of (date, amount, description) can, as soon as one of those three is a default.
FundQuill has no CSV import to check. It is on that product's roadmap as not yet built, and the xlsx path reads cells by address rather than by mapped header name, so there is no column map there either.
What was and was not verified
Read directly, as source, at pinned commits: the importer before and after its fix and after the
follow-up for short rows, its parser tests, its dedupe key, its architecture note and its changelog
entry; pandas' usecols validator and docstring; Papa Parse's header handling; CPython's
DictReader documentation. The three issue reports were read as filed, and the quoted invariant is
quoted from the report rather than from the repository file the report cites, which was not
reachable from here.
The reader table is measured, run today, on CPython 3.13.18, pandas 3.0.5, Papa Parse 5.7.1 and Node 22.23.5, and every row of it came out the same again on CPython 3.12.3, pandas 2.1.4 and Node 24.19.0. The hash walkthrough is not that application running. It is the canonical string and digest reconstructed in Python exactly as the quoted C# builds them, which is enough to show that two rows yield one key, and the import counts beside it follow from the quoted handler rather than from an observed run. The .NET project was not built or executed here, so nothing is claimed about its behaviour beyond what its source, its tests and its own changelog state.
Both reports are one project each, and neither is evidence about how common any of this is. This post makes no claim about how often it happens. It is about a lookup that returns the same answer to two different questions, which is checkable by reading, and which sits in a great deal of import code because the default that causes it is right often enough to look safe.