Skip to content

feat(csv): tell a number from a code - #669

Merged
andiwand merged 1 commit into
mainfrom
feat/csv-value-types
Aug 9, 2026
Merged

feat(csv): tell a number from a code#669
andiwand merged 1 commit into
mainfrom
feat/csv-value-types

Conversation

@andiwand

@andiwand andiwand commented Aug 9, 2026

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

Last of five stacked PRs. Based on #668. Plan: src/odr/internal/csv/PLAN.md.

ValueType is only {unknown, string, float_number} (document_element.hpp:135) and drives exactly one CSS class — text-align:right (html/frontend.cpp:32). So this stays small on purpose.

Per column, not per cell

A reader compares down a column, so one number in a column of prose is not a quantity:

a,b
x,note
y,42     <- string, not a number

The first row is left out of the sample: a header names its column rather than holding a value, and one word would otherwise make every column prose. The header of a numeric column stays text for the same reason.

Empty cells do not break a numeric column.

What the grammar refuses is the point

input verdict why
42, -3.14, 1.5E-3 number
007, 0123456789012 string a leading zero is what tells a code from a quantity
1,234 / 1.234,56 string a thousands separator does not say which side of the Atlantic wrote it
2026-08-09, 03/04/2026 string 03/04/2026 is two different days; guessing gets it wrong confidently

Dates are left alone entirely rather than half-supported.

Quoting is not consulted. RFC 4180 quoting is lexical — Excel quotes any field holding a separator, a quote or a newline, and plenty of writers quote everything — so it carries no type information. This was the one item in the original brief I pushed back on, and it stays pushed back.

The raw string is always what gets displayed; the value type only changes alignment.

Tests

is_number is a free function and tested directly, plus the column rules through the sheet. 577 unit tests and 234 reference-output tests green.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8dd4dc9792

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/odr/internal/csv/csv_document.cpp Outdated
@andiwand
andiwand force-pushed the feat/csv-value-types branch from 8dd4dc9 to 01524bb Compare August 9, 2026 08:17
@andiwand
andiwand force-pushed the feat/csv-value-types branch from 01524bb to 4b3165d Compare August 9, 2026 08:33
@andiwand
andiwand force-pushed the feat/csv-value-types branch from 4b3165d to 0acbaa5 Compare August 9, 2026 08:54
@andiwand
andiwand force-pushed the feat/csv-value-types branch from 0acbaa5 to 29b5d42 Compare August 9, 2026 09:09
@andiwand
andiwand force-pushed the feat/csv-value-types branch from 29b5d42 to b97900d Compare August 9, 2026 11:09
@andiwand
andiwand force-pushed the feat/csv-value-types branch from b97900d to 4522451 Compare August 9, 2026 11:13
@andiwand
andiwand force-pushed the feat/csv-value-types branch from 4522451 to 7492056 Compare August 9, 2026 11:25
@andiwand
andiwand force-pushed the feat/csv-value-types branch from 7492056 to 1ae568b Compare August 9, 2026 11:30
Base automatically changed from feat/csv-sheet to main August 9, 2026 11:31
`ValueType` is only `{unknown, string, float_number}` and drives one CSS class
— right alignment — so this stays small on purpose.

Decided per *column*, not per cell: a reader compares down a column, so one
number in a column of prose is not a quantity. The first row is left out of the
sample, because a header names its column rather than holding a value, and one
word would otherwise make every column prose. The header of a numeric column
stays text for the same reason.

The grammar is strict, and what it refuses is the point. A leading zero is what
tells `007` and `0123456789012` from quantities. A thousands separator does not
say which side of the Atlantic wrote it — `1,234` is a thousand or one point
two three four depending on where you live, and a csv does not carry that. Dates
are left alone entirely: `03/04/2026` is two different days and guessing gets it
wrong confidently.

Quoting is not consulted. RFC 4180 quoting is lexical — Excel quotes any field
holding a separator, a quote or a newline, and plenty of writers quote
everything — so it carries no type information at all.

The raw string stays what is displayed either way.

The inference walks the fields a file holds, not the rectangle they span. A
sheet is rectangular even where the file is not, so a single wide record widens
every row: sampling `rows * columns` cells would have a file of a hundred
thousand short records plus one wide one pay for ten billion lookups on open,
before the renderer's cap can matter.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSgWdLTSLCWDeFvbVwZDVU
@andiwand
andiwand force-pushed the feat/csv-value-types branch from 1ae568b to d5d9449 Compare August 9, 2026 11:35
@andiwand
andiwand enabled auto-merge (squash) August 9, 2026 11:41
@andiwand
andiwand merged commit d942dac into main Aug 9, 2026
36 checks passed
@andiwand
andiwand deleted the feat/csv-value-types branch August 9, 2026 11:51
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