-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-114123: migrate docstring from _csv to csv #114124
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ac1e4ca
migrate docstring from _csv to csv
smontanaro b2a5e66
two suggestions by AA-Turner
smontanaro 64301bd
move __version__ from _csv to csv, remove from csv.__all__
smontanaro 998a944
+ NEWS item
smontanaro bef4811
markup
smontanaro 3e540c6
restore test__all__
smontanaro 4d4d2b4
Update the docstring title
AA-Turner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,6 +1,66 @@ | ||||||
|
||||||
""" | ||||||
csv.py - read/write/investigate CSV files | ||||||
AA-Turner marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
This module provides classes that assist in the reading and writing | ||||||
of Comma Separated Value (CSV) files, and implements the interface | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
described by PEP 305. Although many CSV files are simple to parse, | ||||||
the format is not formally defined by a stable specification and | ||||||
is subtle enough that parsing lines of a CSV file with something | ||||||
like line.split(",") is bound to fail. The module supports three | ||||||
basic APIs: reading, writing, and registration of dialects. | ||||||
|
||||||
|
||||||
DIALECT REGISTRATION: | ||||||
|
||||||
Readers and writers support a dialect argument, which is a convenient | ||||||
handle on a group of settings. When the dialect argument is a string, | ||||||
it identifies one of the dialects previously registered with the module. | ||||||
If it is a class or instance, the attributes of the argument are used as | ||||||
the settings for the reader or writer: | ||||||
|
||||||
class excel: | ||||||
delimiter = ',' | ||||||
quotechar = '"' | ||||||
escapechar = None | ||||||
doublequote = True | ||||||
skipinitialspace = False | ||||||
lineterminator = '\r\n' | ||||||
quoting = QUOTE_MINIMAL | ||||||
|
||||||
SETTINGS: | ||||||
|
||||||
* quotechar - specifies a one-character string to use as the | ||||||
quoting character. It defaults to '"'. | ||||||
* delimiter - specifies a one-character string to use as the | ||||||
field separator. It defaults to ','. | ||||||
* skipinitialspace - specifies how to interpret spaces which | ||||||
immediately follow a delimiter. It defaults to False, which | ||||||
means that spaces immediately following a delimiter is part | ||||||
of the following field. | ||||||
* lineterminator - specifies the character sequence which should | ||||||
smontanaro marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
terminate rows. | ||||||
* quoting - controls when quotes should be generated by the writer. | ||||||
It can take on any of the following module constants: | ||||||
|
||||||
csv.QUOTE_MINIMAL means only when required, for example, when a | ||||||
field contains either the quotechar or the delimiter | ||||||
csv.QUOTE_ALL means that quotes are always placed around fields. | ||||||
csv.QUOTE_NONNUMERIC means that quotes are always placed around | ||||||
fields which do not parse as integers or floating point | ||||||
numbers. | ||||||
csv.QUOTE_STRINGS means that quotes are always placed around | ||||||
fields which are strings. Note that the Python value None | ||||||
is not a string. | ||||||
csv.QUOTE_NOTNULL means that quotes are only placed around fields | ||||||
that are not the Python value None. | ||||||
csv.QUOTE_NONE means that quotes are never placed around fields. | ||||||
* escapechar - specifies a one-character string used to escape | ||||||
the delimiter when quoting is set to QUOTE_NONE. | ||||||
* doublequote - controls the handling of quotes inside fields. When | ||||||
True, two consecutive quotes are interpreted as one during read, | ||||||
and when writing, each quote character embedded in the data is | ||||||
written as two quotes | ||||||
""" | ||||||
|
||||||
import re | ||||||
|
@@ -9,15 +69,14 @@ | |||||
unregister_dialect, get_dialect, list_dialects, \ | ||||||
field_size_limit, \ | ||||||
QUOTE_MINIMAL, QUOTE_ALL, QUOTE_NONNUMERIC, QUOTE_NONE, \ | ||||||
QUOTE_STRINGS, QUOTE_NOTNULL, \ | ||||||
__doc__ | ||||||
QUOTE_STRINGS, QUOTE_NOTNULL | ||||||
from _csv import Dialect as _Dialect | ||||||
|
||||||
from io import StringIO | ||||||
|
||||||
__all__ = ["QUOTE_MINIMAL", "QUOTE_ALL", "QUOTE_NONNUMERIC", "QUOTE_NONE", | ||||||
"QUOTE_STRINGS", "QUOTE_NOTNULL", | ||||||
"Error", "Dialect", "__doc__", "excel", "excel_tab", | ||||||
"Error", "Dialect", "excel", "excel_tab", | ||||||
"field_size_limit", "reader", "writer", | ||||||
"register_dialect", "get_dialect", "list_dialects", "Sniffer", | ||||||
"unregister_dialect", "__version__", "DictReader", "DictWriter", | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.