Changed the csv.reader() fileobj argument to interable. This give us

much more flexibility in processing filtered data.
Made the example excel dialect match the dialect in csv.py.
Added explanation of doublequote.
Added explanation of csv.QUOTE_NONE.
This commit is contained in:
Dave Cole 2003-02-02 12:25:23 +00:00
parent ccc70922b4
commit 534feb5366
1 changed files with 14 additions and 7 deletions

View File

@ -89,11 +89,11 @@ Module Interface
The module supports two basic APIs, one for reading and one for The module supports two basic APIs, one for reading and one for
writing. The basic reading interface is:: writing. The basic reading interface is::
obj = reader(fileobj [, dialect='excel2000'] obj = reader(iterable [, dialect='excel2000']
[optional keyword args]) [optional keyword args])
A reader object is an iterable which takes a file-like object opened A reader object is an iterable which takes an interable object which
for reading as the sole required parameter. The optional dialect returns lines as the sole required parameter. The optional dialect
parameter is discussed below. It also accepts several optional parameter is discussed below. It also accepts several optional
keyword arguments which define specific format settings for the parser keyword arguments which define specific format settings for the parser
(see the section "Formatting Parameters"). Readers are typically used (see the section "Formatting Parameters"). Readers are typically used
@ -153,9 +153,10 @@ construct variant dialects by subclassing. The "excel" dialect is
implemented as follows:: implemented as follows::
class excel: class excel:
quotechar = '"'
delimiter = ',' delimiter = ','
quotechar = '"'
escapechar = None escapechar = None
doublequote = True
skipinitialspace = False skipinitialspace = False
lineterminator = '\r\n' lineterminator = '\r\n'
quoting = QUOTE_MINIMAL quoting = QUOTE_MINIMAL
@ -188,12 +189,13 @@ parameters are also the keys for the input and output mapping objects
for the set_dialect() and get_dialect() module functions. for the set_dialect() and get_dialect() module functions.
- ``quotechar`` specifies a one-character string to use as the quoting - ``quotechar`` specifies a one-character string to use as the quoting
character. It defaults to '"'. character. It defaults to '"'. Setting this to None has the same
effect as setting quoting to csv.QUOTE_NONE.
- ``delimiter`` specifies a one-character string to use as the field - ``delimiter`` specifies a one-character string to use as the field
separator. It defaults to ','. separator. It defaults to ','.
- ``escapechar`` specifies a one character string used to escape the - ``escapechar`` specifies a one-character string used to escape the
delimiter when quotechar is set to None. delimiter when quotechar is set to None.
- ``skipinitialspace`` specifies how to interpret whitespace which - ``skipinitialspace`` specifies how to interpret whitespace which
@ -215,7 +217,12 @@ for the set_dialect() and get_dialect() module functions.
csv.QUOTE_NONNUMERIC means that quotes are always placed around csv.QUOTE_NONNUMERIC means that quotes are always placed around
fields which contain characters other than [+-0-9.]. fields which contain characters other than [+-0-9.].
- ``doublequote`` (tbd) csv.QUOTE_NONE means that quotes are never placed around
fields.
- ``doublequote`` controls the handling of quotes inside fields. When
True two consecutive quotes are interpreted as one during read, and
when writing, each quote is written as two quotes.
- are there more to come? - are there more to come?