[Python-checkins] r59778 - python/trunk/Doc/library/csv.rst

georg.brandl python-checkins at python.org
Sun Jan 6 17:04:57 CET 2008


Author: georg.brandl
Date: Sun Jan  6 17:04:56 2008
New Revision: 59778

Modified:
   python/trunk/Doc/library/csv.rst
Log:
#1686390: add example for csv.Sniffer use.


Modified: python/trunk/Doc/library/csv.rst
==============================================================================
--- python/trunk/Doc/library/csv.rst	(original)
+++ python/trunk/Doc/library/csv.rst	Sun Jan  6 17:04:56 2008
@@ -220,7 +220,6 @@
 
 The :class:`Sniffer` class provides two methods:
 
-
 .. method:: Sniffer.sniff(sample[, delimiters=None])
 
    Analyze the given *sample* and return a :class:`Dialect` subclass reflecting the
@@ -233,9 +232,17 @@
    Analyze the sample text (presumed to be in CSV format) and return :const:`True`
    if the first row appears to be a series of column headers.
 
-The :mod:`csv` module defines the following constants:
+An example for :class:`Sniffer` use::
+
+   csvfile = open("example.csv")
+   dialect = csv.Sniffer().sniff(csvfile.read(1024))
+   csvfile.seek(0)
+   reader = csv.reader(csvfile, dialect)
+   # ... process CSV file contents here ...
 
 
+The :mod:`csv` module defines the following constants:
+
 .. data:: QUOTE_ALL
 
    Instructs :class:`writer` objects to quote all fields.


More information about the Python-checkins mailing list