Repository navigation
An XLSX header over two rows names each column from both rows - #308
Merged
Merged
Conversation
A range merged across columns of the header row, over text cells in the row under it, makes a header of both rows: each column is named from both (2025 / H1), header_rows is 2, and the values start under it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…erged down Outside the merged range, the second row may hold only cells merged down from the first, so a data row of text is no header. A two-row header with no rows under it cites both rows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
A cell of a megabyte merged over many columns was copied into each joined name, past what the cell budget counts. Each side is cut to more than a column name holds, so the cut is still reported. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…is counted Which columns the header row's merges cover is found in time linear in the merges and the columns. A joined name reads each cell as a name does and records a cut, which the name count reports, and a side that reads as nothing gives way to the other. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…nothing The joined names read each distinct cell once, as the names do, so a long cell merged over many columns costs one scan. A range the cell budget did not spread names only its first column and no longer groups the row under it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…oined cells are called cells Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… it returns Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…dget Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…gainst the cap, as stated Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…header rows is tested Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… read Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
fix/extractor-xlsx-two-row-header
branch
from
November 7, 2026 07:09
3d80f7e to
55e3bf4
Compare
This was referenced Nov 7, 2026
Merged
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.
Related: #157
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
An XLSX header over two rows, a cell merged across columns grouping the names under it, names each column from both rows (
2025 / H1,2025 / H2); before, the second row of names was read as a row of data and the columns were2025and2025 (2).Why
The issue's extraction gate names merged spreadsheet headers. Scoring the reference extractor on a labelled workbook found that a header like
Region | 2025 (merged over two columns) | Note, withH1andH2under2025, reads as one header row: the columns areRegion,2025,2025 (2),Note, typedmixed, and the first data row isRegion, H1, H2, Note. A dataset built from it has wrong column names, mixed types where the values are numbers, and a spurious row in every aggregate.Design
xlsxfile, after the sheet's merges are spread: when a range merged across columns sits in the header row alone, and the row right under it holds text cells under that range and, everywhere else, nothing or only cells merged down from the header row (RegionoverA1:A2), the header is both rows. Any other cell in that row, text or not, makes it data. Each column's name is the first row's cell and the second's joined by/; a cell merged down both rows (Region,Note) or with nothing under it is its own name, and one with nothing above (a range merged for its formatting alone) takes the second row's (_named_over). A joined name is each cell's name as_namesreads it (tabular.read_name, folded), so a cell padded with spaces reads as its words, and a cell whose name reads as nothing gives way to the other row's; text past what a name reads is counted as cut (Rows.cut_names, which_namesadds to its count); it keeps at most 1,001 characters of each cell, what a name reads (tabular.NAME_READ_CHARS, now the one bound_namesand the join share, more than the 500 a column's name holds, so a cut is still counted): a cell of a megabyte merged over thousands of columns would otherwise be copied into each of their names, a cost the artifact's cell budget does not see.tabular.Rowsgainsheader_rows(1 by default), which becomes the table'sheader_rows(2 here; the contract already allows any count), and the span of a header-only block and of a table with no rows under its header. The data rows start under the second row; the table's locator still starts at the header's first row._namesreads it once, however many columns a merge spreads it over (the join cachesread_nameby cell), and a pair of cells over many columns shares one joined name, which_namesreads once too. A range the cell budget left unspread groups nothing (_spreadnow returns the ranges it skipped, as they were read, rather than counting them); one merged with no value does, and so does one whose last cell holds a value of its own (a hidden cell's kept content)._covered), so a sheet of a million merges in its header row costs no more than reading them, asMAX_MERGESpromises.xlsxfile.PARSER_VERSIONbecomes 2.A title merged over the whole first row above a header row (
Sales 2025overRegion | Q1) meets the rule too, and its text heads each name (Sales 2025 / Region). So does a first data row of text alone under merges that cover every column it fills (NameoverA:B,ContactoverC:D, thenAlice | Smith | [email protected] | Paris): nothing in the sheet tells it from sub-headers under the groups, so it reads as the second header row, as the docs say, and the columns keep those names until the sheet is changed. Telling them apart would take reading the rows below for a pattern, a guess either way. That keeps the title's text in the table instead of a first data row of names; reading it as a sheet title apart from the header would be a further rule, left out here.Alternatives: a two-row header whenever the second row is all text (a data row of names reads as a header); asking the caller to say how many header rows a sheet has (no option for it exists, and every caller would have to know its sheets).
Scope and risk
Touches the reference extractor's XLSX reader and the shared
tabular.Rows; CSV, Parquet and PDF tables keep one header row. No server, wire or schema change. A workbook ingested earlier keeps its artifact and dataset until extracted again. Extracted again, a workbook with a two-row header gets new column names, so an approval of its dataset does not carry over (an approval carries only to a revision with the same column names in the same order): its dataset is inferred again, and while it needs clarificationknowledge.queryanswers422until a writer approves it again.Compatibility, rollout and rollback
tables[].header_rowswas already in the contract and is now 2 for such a header.Tests
tests/unit/test_document_extraction_tables.py: the two-row header reads asRegion,2025 / H1,2025 / H2,Note(typedstring,number,number,string), one data row,header_rows2, the table cited from row 1 and its first row block from row 3; a title merged over the header row heads each name; the existing workbook whose merged header has data under it still reads one header row, and so does a sheet whose row under a merged header is data with a text or a number in a column outside the merge (Aliceor17in A2); a sheet of a two-row header and no rows cites rows 1 to 2 in its table and its header block; a column with nothing under its name beside a two-row header keeps its name; a range merged with no value takes the names under it; a header cell padded with a thousand spaces over a second header row reads asRevenue / H1with nothing counted as cut, one with text after the padding is cut and counted, and one of padding then text gives way to the names under it, counted as cut;_coveredmarks the columns a million spans cover in one pass; a merged cell over 50 columns is read once; a merge the cell budget left unspread groups no header, a narrow one and one past the last column alike, run through the real budget (a budget of six cells: the rows take five, the merge is read and is too big to spread; without the filter on the skipped ranges both cases fail); the second header row counts against the rows a table holds, as the docs say (with the cap at three rows, a two-row header keeps two of its three rows and counts the third,S rows 5-), since the row cap is applied while the sheet streams, before the header is known; a megabyte header cell merged over 200 columns over a second header row gives names cut to 500 characters and counted as cut, and a joined name holds at most 1,001 characters of either cell, what a name reads.make format lint typecheck.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. Checked: the guard against data under a merged header, the rows and locators, and a review at every push.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).main; no merged migration is edited. (Not applicable: no migration.)hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version. (Not applicable: no plugin file changes.)npm --prefix frontend run build) and its tests pass, iffrontend/changed. (Not applicable.)docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code