Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Doc/library/csv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ The :mod:`!csv` module defines the following functions:
automatic data type conversion is performed unless the :data:`QUOTE_NONNUMERIC` format
option is specified (in which case unquoted fields are transformed into floats).

Assume that :file:`eggs.csv` contains:

.. code-block:: text

Spam Spam Spam Spam Spam |Baked Beans|
Spam |Lovely Spam| |Wonderful Spam|

A short usage example::

>>> import csv
Expand Down Expand Up @@ -110,6 +117,13 @@ The :mod:`!csv` module defines the following functions:
spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])
spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])

The example writes :file:`eggs.csv` with this content:

.. code-block:: text

Spam Spam Spam Spam Spam |Baked Beans|
Spam |Lovely Spam| |Wonderful Spam|


.. function:: register_dialect(name, /, dialect='excel', **fmtparams)

Expand Down Expand Up @@ -177,6 +191,14 @@ The :mod:`!csv` module defines the following classes:
.. versionchanged:: 3.8
Returned rows are now of type :class:`dict`.

Assume that :file:`names.csv` contains:

.. code-block:: text

first_name,last_name
Eric,Idle
John,Cleese

A short usage example::

>>> import csv
Expand Down Expand Up @@ -228,6 +250,15 @@ The :mod:`!csv` module defines the following classes:
writer.writerow({'first_name': 'Lovely', 'last_name': 'Spam'})
writer.writerow({'first_name': 'Wonderful', 'last_name': 'Spam'})

The example writes :file:`names.csv` with this content:

.. code-block:: text

first_name,last_name
Baked,Beans
Lovely,Spam
Wonderful,Spam


.. class:: Dialect

Expand Down
Loading