mirror of
https://github.com/python/cpython.git
synced 2025-10-03 05:35:59 +00:00
[3.12] gh-113046: Revise csv.reader doc (GH-113207) (#113210)
Clarify nature of csvfile.
(cherry picked from commit 84df3172ef
)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
parent
d77d62ab79
commit
37712aced6
1 changed files with 7 additions and 4 deletions
|
@ -55,10 +55,11 @@ The :mod:`csv` module defines the following functions:
|
||||||
|
|
||||||
.. function:: reader(csvfile, dialect='excel', **fmtparams)
|
.. function:: reader(csvfile, dialect='excel', **fmtparams)
|
||||||
|
|
||||||
Return a reader object which will iterate over lines in the given *csvfile*.
|
Return a :ref:`reader object <reader-objects>` that will process
|
||||||
*csvfile* can be any object which supports the :term:`iterator` protocol and returns a
|
lines from the given *csvfile*. A csvfile must be an iterable of
|
||||||
string each time its :meth:`!__next__` method is called --- :term:`file objects
|
strings, each in the reader's defined csv format.
|
||||||
<file object>` and list objects are both suitable. If *csvfile* is a file object,
|
A csvfile is most commonly a file-like object or list.
|
||||||
|
If *csvfile* is a file object,
|
||||||
it should be opened with ``newline=''``. [1]_ An optional
|
it should be opened with ``newline=''``. [1]_ An optional
|
||||||
*dialect* parameter can be given which is used to define a set of parameters
|
*dialect* parameter can be given which is used to define a set of parameters
|
||||||
specific to a particular CSV dialect. It may be an instance of a subclass of
|
specific to a particular CSV dialect. It may be an instance of a subclass of
|
||||||
|
@ -449,6 +450,8 @@ Dialects support the following attributes:
|
||||||
When ``True``, raise exception :exc:`Error` on bad CSV input.
|
When ``True``, raise exception :exc:`Error` on bad CSV input.
|
||||||
The default is ``False``.
|
The default is ``False``.
|
||||||
|
|
||||||
|
.. _reader-objects:
|
||||||
|
|
||||||
Reader Objects
|
Reader Objects
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue