summaryrefslogtreecommitdiffstats
path: root/Doc/library/csv.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-12-05 17:56:50 (GMT)
committerGeorg Brandl <georg@python.org>2007-12-05 17:56:50 (GMT)
commit722e1011c937ee6adb3fbb37c00fc58315ba0918 (patch)
tree16d400b4be41239f93884c0cd8efa0987cb7049b /Doc/library/csv.rst
parent395fe44210ab03a4fa430df4cd56a0c37d3f2437 (diff)
downloadcpython-722e1011c937ee6adb3fbb37c00fc58315ba0918.zip
cpython-722e1011c937ee6adb3fbb37c00fc58315ba0918.tar.gz
cpython-722e1011c937ee6adb3fbb37c00fc58315ba0918.tar.bz2
Add examples to csv, pprint and traceback docs.
Written by Ross for GHOP.
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])