summaryrefslogtreecommitdiffstats
path: root/Doc/library/csv.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/csv.rst')
-rw-r--r--Doc/library/csv.rst19
1 files changed, 17 insertions, 2 deletions
diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst
index a46c7ba..1d63080 100644
--- a/Doc/library/csv.rst
+++ b/Doc/library/csv.rst
@@ -45,8 +45,6 @@ using the :class:`DictReader` and :class:`DictWriter` classes.
.. seealso::
- .. % \seemodule{array}{Arrays of uniformly types numeric values.}
-
:pep:`305` - CSV File API
The Python Enhancement Proposal which proposed this addition to Python.
@@ -77,6 +75,15 @@ The :mod:`csv` module defines the following functions:
All data read are returned as strings. No automatic data type conversion is
performed.
+ A short usage example::
+
+ >>> import csv
+ >>> spamReader = csv.reader(open('eggs.csv'), delimiter=' ', quotechar='|')
+ >>> for row in spamReader:
+ ... print ', '.join(row)
+ Spam, Spam, Spam, Spam, Spam, Baked Beans
+ Spam, Lovely Spam, Wonderful Spam
+
.. versionchanged:: 2.5
The parser is now stricter with respect to multi-line quoted fields. Previously,
if a line ended within a quoted field without a terminating newline character, a
@@ -106,6 +113,14 @@ The :mod:`csv` module defines the following functions:
CSV files without preprocessing the data returned from a ``cursor.fetch*`` call.
All other non-string data are stringified with :func:`str` before being written.
+ A short usage example::
+
+ >>> import csv
+ >>> spamWriter = csv.writer(open('eggs.csv', 'w'), delimiter=' ',
+ ... quotechar='|', quoting=QUOTE_MINIMAL)
+ >>> spamWriter.writerow(['Spam'] * 5 + ['Baked Beans'])
+ >>> spamWriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])
+
.. function:: register_dialect(name[, dialect][, fmtparam])