Skip to content

gh-80678: Add comment on preferred csv delimiters #96199

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

slateny
Copy link
Contributor

@slateny slateny commented Aug 23, 2022

https://docs.python.org/dev/library/csv.html#csv.Sniffer.sniff

See

self.preferred = [',', '\t', ';', ' ', ':']
for the list of preferred delimiters, and see

cpython/Lib/csv.py

Lines 369 to 375 in 1499d73

# if there's more than one, fall back to a 'preferred' list
if len(delims) > 1:
for d in self.preferred:
if d in delims.keys():
skipinitialspace = (data[0].count(d) ==
data[0].count("%c " % d))
return (d, skipinitialspace)
for choosing the preferred delimiters

@bedevere-bot bedevere-bot added docs Documentation in the Doc dir skip news awaiting review labels Aug 23, 2022
@@ -275,6 +275,8 @@ The :mod:`csv` module defines the following classes:
reflecting the parameters found. If the optional *delimiters* parameter
is given, it is interpreted as a string containing possible valid
delimiter characters.
If not excluded by the *delimiters* parameter, and if there is ambiguity,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the documentation here not added to the def sniff docstring? That would be a natural place for documentation that is available from the command line or IDE.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what information should go into the docstring vs in the docs. I imagine there's some duplicate, but surely not everything in the docs goes into the docstring and vice-versa. The docstring of sniff is looking a bit empty though, so it could use some work for sure.

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
@slateny slateny changed the title gh-80678: Add comment on preferred delimiters gh-80678: Add comment on preferred csv delimiters Jan 8, 2023
@python-cla-bot
Copy link

The following commit authors need to sign the Contributor License Agreement:

CLA signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants