Repository navigation
JSE-F2: detect two-row headers without merges (CSV) - #117
Merged
Merged
Conversation
detectHeader took the first of two stacked header rows as the header
and the second as data, with high confidence, whenever there were no
merges to tie them together (always the case in CSV).
- The row directly below a single high-confidence header joins it when
it is all text and every text cell sits on a column whose next five
non-empty values are all typed. A data row can't look like that: it
would make each of those columns mixed.
- When no single row fills the table, two adjacent text rows that fill
it together, with the lower one passing the same test, are a two-row
header ("Name,Q1," over ",Jan,Feb", toCsv of header groups).
- When the row under the header is all text but only partly fits, it
stays data and the confidence drops to 'low'.
react-data-import's header fixtures are copied into
test/fixtures/import and checked here; only two-header-rows.csv
changes (rows [0] -> [0, 1]). docs/api.md describes the new rules.
This was referenced Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
header: 'auto'read a two-row header without merges as a one-row header, withconfidence: 'high', and turned the second header row into data. CSV never has merges, so this hit every CSV with a two-row header.header: { rows: 2 }already worked.The rule (
src/internal/import/header.ts)toCsvwrites for header groups:Name,Q1,over,Jan,Feb.'low', so a UI asks the user.It is still deterministic, with no scores or weights.
Region,Sales,Sales/,Q1,Q2/ numbers[0]high;Sales: 'Q1'as the first data row[0, 1]high;Region,Sales / Q1,Sales / Q2Name,Q1,/,Jan,Feb/ numbers[0]low; keysName, Q1, C[0, 1]high; keysName, Q1 / Jan, Feb*Temp,Pressure/°C,hPa/ numbers[0]high; units as data[0, 1]high;Temp / °C,Pressure / hPaName,Amount/Ada,n/a/Bob,10[0]high[0]lowName,City,Amount/Bob,Paris,/Ada,Oslo,10[0]high[0]high (unchanged)* Without merges, the flattening can't know that
Q1also coversFeb. Filling a group title to the right over empty cells is a separate decision for the flattening step and is not part of this PR.Fixtures
react-data-import's header fixtures are copied unchanged into
test/fixtures/import/(4 CSV, 6 xlsx; README there) and checked intest/import/fixtures.test.ts. Onlytwo-header-rows.csvchanges, from[0]to[0, 1]. Every other fixture keeps its rows and'high'confidence. Separately, react-data-import's own suite was run against this build: 94 tests pass, and 1 fails, the test that pins today's behaviour fortwo-header-rows.csv. That test (and its docs line) needs updating in react-data-import once this ships.Checks
test/import/header.test.ts(stacked rows, units row, group row, a text data row kept, the low-confidence cases)docs/api.md(Header detection) describes the new rules; patch changeset.