diff options
author | Georg Brandl <georg@python.org> | 2008-01-06 16:04:56 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-01-06 16:04:56 (GMT) |
commit | 14aaee143d63b41b4a8b28bf4f81f5fceae24b97 (patch) | |
tree | b332bb89fb94627103c332736b32cb4fc7a8b557 /Doc | |
parent | 2cb103ffa9b7fb115f1fdea8859c899bcab609a3 (diff) | |
download | cpython-14aaee143d63b41b4a8b28bf4f81f5fceae24b97.zip cpython-14aaee143d63b41b4a8b28bf4f81f5fceae24b97.tar.gz cpython-14aaee143d63b41b4a8b28bf4f81f5fceae24b97.tar.bz2 |
#1686390: add example for csv.Sniffer use.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/csv.rst | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst index 1d63080..89c9bf1 100644 --- a/Doc/library/csv.rst +++ b/Doc/library/csv.rst @@ -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,9 +232,17 @@ 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 Instructs :class:`writer` objects to quote all fields. |