Skip to content

Add csvformat --describe for input dialect diagnostics - #1368

Open
pauloflp wants to merge 1 commit into
wireservice:masterfrom
pauloflp:csvformat-describe-dialect
Open

pauloflp wants to merge 1 commit into
wireservice:masterfrom
pauloflp:csvformat-describe-dialect

Conversation

@pauloflp

Copy link
Copy Markdown

Adds csvformat --describe to inspect the effective input dialect, implementing the diagnostic-report direction suggested in #1011 (and #1282). For example, printf 'a;b\n1;2\n' | csvformat --describe now reports Delimiter: ';', together with quote, escape, doublequote, quoting, and initial-space settings.

The report uses agate's sniffer, honors explicit input overrides and skipped lines, and avoids parsing data rows. -y/--snifflimit controls diagnostic sampling (1024 characters by default, 0 disables sniffing, -1 reads the full file). Normal conversion retains its existing behavior. Line terminators are omitted because Sniffer does not infer them. Documentation and regression coverage are included.

Revalidation of the original long-row fixture: with current dependencies, both 10 and 100 rows complete under csvstat's default limit with a sniffing warning and comma fallback. The new diagnostic with -y -1 reports a space for the 100-row fixture, making the sampling difference inspectable. This PR does not change exception handling or add sample-size warnings.

Validation on Python 3.12.14:

  • All 11 new diagnostic tests fail against the original implementation and pass with this change.
  • pytest tests/test_utilities/test_csvformat.py -q: 40 passed.
  • Full pytest -q: 361 passed, 4 skipped, 31 subtests passed, 1 existing failure. TestCSVStat.test_decimal_format expects 9,748.346 but receives 9748.346; the same failure was reproduced in a clean worktree at base commit 6d19c625214977ab2988e674441ca24638bc12d3, without these changes.
  • Changed-file flake8, isort check, check-manifest, and git diff --check 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