Skip to content

fix(csv): preserve semicolon schema for header-only exports - #18

Merged
axisrow merged 2 commits into
mainfrom
ao/wordstat-10/issue-15-csv
Aug 21, 2026
Merged

axisrow merged 2 commits into
mainfrom
ao/wordstat-10/issue-15-csv

Conversation

@axisrow

@axisrow axisrow commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • fall back to Wordstat semicolon dialect when Sniffer has insufficient input
  • reject headers retaining an unparsed semicolon delimiter
  • add UTF-8 BOM, CR-only, comma-in-header, malformed-header, and multiline CSV tests

Fixes #15

Tests

  • uv run pytest -q (116 passed)
  • uv run ruff check . (All checks passed)
  • git diff --check

PR opened for review; not merged.

The header-only fallback added for issue #15 hardcoded semicolon as the
separator when csv.Sniffer can't establish one from a single line. But
Wordstat also exports tab-delimited views (see "Fix the CSV sniffer's
tab delimiter"), so a tab-delimited header-only export still collapsed
into one column with embedded tabs — the exact silent-schema-corruption
bug issue #15 was filed about, reproduced for the tab case.

- choose the fallback delimiter by counting ';' vs '\t' occurrences in
  the header line instead of hardcoding ';'
- extend the unparsed-delimiter header guard to reject both ';' and '\t'
- add regression tests for the tab-delimited header-only case and for
  the guard rejecting an unparsed tab
- bring CLAUDE.md's csv_io.py section in line with the actual encoding
  (UTF-8 with BOM, cp1251 as fallback) and line terminator (lone CR,
  normalized by Path.read_text's universal newlines) per issue #15 item 3
@axisrow

axisrow commented Aug 21, 2026

Copy link
Copy Markdown
Owner Author

🔍 Local review (cycle 1) — round 9f7ebcb2-1193-40af-a64f-df62499e1f96

Reviewed locally (/review + Codex companion), no bots pinged.

Verdict Reviewer Finding Location
claude No issues found; change is small, logically sound, no dead code left behind src/wordstat/csv_io.py
codex No ship-blocking defect; delimiter ambiguity fails closed and preserves the raw CSV src/wordstat/csv_io.py

Result: both reviewers approved — no FIX/SKIP findings this round.

@axisrow

axisrow commented Aug 21, 2026

Copy link
Copy Markdown
Owner Author

📋 Review summary — all cycles

Cycle Reviewer Finding Verdict Resolution
1 claude No issues found in the tab/semicolon fallback-delimiter fix Approved, no action needed
1 codex No ship-blocking defect; delimiter ambiguity fails closed Approved, no action needed

Totals: 0 FIX, 0 SKIP, 0 UNVERIFIED. Both configured reviewers (/review built-in + Codex companion) reviewed head 7956cf5 and found nothing blocking.

@axisrow
axisrow merged commit 6be29c4 into main Aug 21, 2026
1 check passed
@axisrow
axisrow deleted the ao/wordstat-10/issue-15-csv branch August 21, 2026 05:41
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.

csv_io: на CSV из одного заголовка Sniffer выбирает запятую и молча ломает схему колонок

1 participant