Repository navigation
Keep the header when a body cell repeats its column label - #196
Merged
Merged
Conversation
A text column's first-row value recurring below no longer counts as a data vote alongside type evidence; it only decides tables that have no type evidence at all. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HZSgx9EcGdipZuLbdXjMsi
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.
Slack thread: https://firecrawl.slack.com/archives/C08LS3XTELB/p1792189170824319
Problem
For CSV/xlsx/ods (no declared header row),
resolve_header_rowscounted a "data" vote whenever a text column's first-row value recurred in the body (case-insensitive, trimmed). That vote tied with real type evidence, e.g. a numeric column under a text label, so detection returned 0: the output got a blank header row and the real labels were pushed into the body.Repro:
city,region,pop / Paris,north,100 / Lyon,region,200 / Nice,east,300rendered as| | | |followed by| city | region | pop |in the body.Fix
Repeated first-row values now go into a separate
repeat_votestally:header_votes > data_votes).x,aka / y,aka / z,aka) are unchanged.Behaviour change: a table with type evidence for a header plus two or more repeated values now also keeps its header. Before, the repeats outvoted it.
Tests
New
tests/header_collision.rsbuilds each case in memory as CSV, xlsx and ods. For every case and format it asserts that the first output line is the header (| city | region | pop |, or| city | Status | pop |for the Status case) and that the table has data rows + 2 lines. Cases: collision in col A, collision in col B, upper case, mixed case, padded, collision on the first data row,Statuscontainingstatus, and no collision. There is also an exact-output test for the no-collision case, which passes on the old code too.cargo test(all tests plus the snapshot corpus, no snapshot changes),cargo clippy --all-targets -- -D warningsandcargo fmt --checkall pass.Generated by Claude Code
Summary by cubic
Fixes header detection so a body cell that repeats its column label no longer overrides real type evidence. Previously a repeat counted as a vote against a header, so tables like
city,region,popwith a body row containingLyon,region,200rendered with a blank header row and the labels pushed into the body; now type evidence decides on its own, and repeats only settle tables that have no type evidence.Behavior change: a table with type evidence for a header plus two or more repeated labels now keeps its header, where the repeats used to outvote it. Adds
tests/header_collision.rscovering collisions across CSV, xlsx, and ods.Written for commit 99b23e0. Summary will update on new commits.