Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[csv-] warn when guessed option differs from default #2690

Merged
merged 1 commit into from
Mar 4, 2025

Conversation

midichef
Copy link
Contributor

@midichef midichef commented Jan 23, 2025

When csv is guessed without a filetype, visidata uses Python's csv library to guess the parsing options using csv.Sniffer. For the simplest csv files, it seems that doublequote is False, whereas the default in visidata is True. That can surprise users, as it did in #2689.

This PR makes the guessing process more obvious. It outputs a warning for all guessed CSV options that differ from visidata's defaults:

echo a,b |vd
...
guessed option csv_doublequote=False
guessed option csv_skipinitialspace=False

(versions that do the silent guessing are 3.0 and up)

Or should we override the Sniffer guesses to use visidata's defaults?

@midichef midichef changed the title [csv-] warn when guessed option differs from default #2690 [csv-] warn when guessed option differs from default Jan 24, 2025
@saulpw
Copy link
Owner

saulpw commented Feb 28, 2025

Thanks @midichef, this will be especially helpful for diagnosing when csv sniffing goes awry.

@anjakefala anjakefala merged commit 7e5ce4f into saulpw:develop Mar 4, 2025
14 checks passed
@midichef midichef deleted the csv_option_guess_warn branch March 4, 2025 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants