[Python-checkins] r43613 - python/trunk/Doc/lib/libcsv.tex
Walter Dörwald
walter at livinglogic.de
Tue Apr 4 09:40:39 CEST 2006
david.goodger wrote:
> Author: david.goodger
> Date: Tue Apr 4 05:05:44 2006
> New Revision: 43613
>
> Modified:
> python/trunk/Doc/lib/libcsv.tex
> Log:
> added another example of Unicode CSV parsing; reworked the example text a bit; corrected notice in the intro and added a link to the examples
> [...]
> class UnicodeReader:
> +
> + """
> + A CSV reader which will iterate over lines in the CSV file "f",
> + which is encoded in the given encoding.
> + """
> +
> def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwds):
> self.reader = csv.reader(f, dialect=dialect, **kwds)
> self.encoding = encoding
> @@ -446,6 +482,12 @@
> return self
>
> class UnicodeWriter:
> +
> + """
> + A CSV writer which will write rows to CSV file "f",
> + which is encoded in the given encoding.
> + """
> +
> def __init__(self, f, dialect=csv.excel, encoding="utf-8", **kwds):
> self.writer = csv.writer(f, dialect=dialect, **kwds)
> self.encoding = encoding
> @@ -457,6 +499,3 @@
> for row in rows:
> self.writerow(row)
> \end{verbatim}
> -
> -They should work just like the \class{csv.reader} and \class{csv.writer}
> -classes but add an \var{encoding} parameter.
These classes will have problems with various non-charmap encodings.
(E.g. the writer will write multiple BOMS for UTF-16). IMHO it would be
better to use the new incremental codecs in these examples.
Bye,
Walter Dörwald
More information about the Python-checkins
mailing list