Skip to content

JSE-F3: carry a group title right over its sub-columns without merges - #118

Merged
securedeveloper merged 1 commit into
mainfrom
jse-f3-group-fill-right
Nov 17, 2026
Merged

securedeveloper merged 1 commit into
mainfrom
jse-f3-group-fill-right

Conversation

@securedeveloper

Copy link
Copy Markdown
Owner

In a multi-row header without merges, which is always the case in CSV, a group title is written once, over the first of its columns: Name,Q1, over ,Jan,Feb. toDataset's headerRows flattening, which importDataset uses, turned that into Name, Q1 / Jan, Feb.

Rule (multiRowTitles in src/dataset.ts)

An empty, unmerged cell in an upper header row takes the nearest non-empty cell to its left in the same row, but only when that column has text in a lower header row (so it is a sub-column).

  • It never fills from left of the table's first column, so a leading empty cell over Name stays empty.
  • It stops at a merged cell, because a real merge already gives the extent. Merged headers (xlsx, fromDataset) are unchanged.
  • A column with no text in the lower header rows is not filled, so it keeps an empty title and its column-letter key.
  • Units rows (Temp over °C) have no empty upper cells, so they are unchanged.
header rows before after
Name,Q1, / ,Jan,Feb Name, Q1 / Jan, Feb Name, Q1 / Jan, Q1 / Feb
,,Q1,, / Name,City,Jan,Feb, Name, City, Q1 / Jan, Feb, `` Name, City, Q1 / Jan, Q1 / Feb, ``
Temp,Pressure / °C,hPa unchanged unchanged
Name,Q1 (merged B:C), / ,Jan,Feb,Notes Name, Q1 / Jan, Q1 / Feb, Notes unchanged

Tests

  • Round trip: toCsv(fromDataset(...header groups...)) then importDataset detects rows [0, 1] with high confidence, and gives back Name, Q1 / Jan … Q2 / May, Notes with the right values.
  • toDataset cases: group titles, leading empty cells, a column with no lower text, a units row, and a merge that wins over the fill.
  • Full suite: 942 pass. Typecheck, lint and docs:check are clean.
  • react-data-import's suite against this build: no fixture result changes from this PR. The one failure is the test pinning the old two-header-rows.csv detection, which JSE-F2 (JSE-F2: detect two-row headers without merges (CSV) #117) already changed. That file has no empty upper cells, so this PR doesn't touch it.

docs/api.md §4.3 describes the rule. Patch changeset.

A multi-row header without merges (CSV) writes a group title once, over
the first of its columns: "Name,Q1," over ",Jan,Feb". toDataset's
headerRows flattening read that as "Name", "Q1 / Jan", "Feb".

An empty, unmerged cell in an upper header row now takes the nearest
non-empty cell to its left in that row, when the column has text in a
lower header row. The fill stops at the table's first column and at a
merged cell (a real merge already gives the extent), so merged headers
and units rows ("Temp" over "°C") are unchanged.

Tests: toCsv of fromDataset header groups imports back with the
original titles; units rows, leading empty cells, columns without
lower text and merges. docs/api.md 4.3 describes the rule.
@securedeveloper
securedeveloper merged commit 0f1ab49 into main Nov 17, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant