#1686390: add example for csv.Sniffer use.

This commit is contained in:
Georg Brandl 2008-01-06 16:04:56 +00:00
parent 2cb103ffa9
commit 14aaee143d
1 changed files with 9 additions and 2 deletions

View File

@ -220,7 +220,6 @@ The :mod:`csv` module defines the following classes:
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,8 +232,16 @@ The :class:`Sniffer` class provides two methods:
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