Terry Reedy schrieb:
In Python 3, a file opened in 'b' mode is for reading and writing bytes
with no encoding/decoding. I believe cvs works with files in text mode
as it returns and expects strings/text for reading and writing. Perhaps
the cvs doc should say must not be opened in 'b' mode. Not
Sibylle Koczian wrote:
> Hello,
>
> I want to put data from a database into a tab separated text file. This
> looks like a typical application for the csv module, but there is a
> snag: the rows I get from the database module (kinterbasdb in this case)
> contain unicode objects and numbers. And of
Sibylle Koczian wrote:
Peter Otten schrieb:
I'd preprocess the rows as I tend to prefer the simplest approach I can come
up with. Example:
def recode_rows(rows, source_encoding, target_encoding):
def recode(field):
if isinstance(field, unicode):
return field.encode(targ
Sibylle Koczian wrote:
> This problem really goes away with Python 3 (tried it on another
> machine), but something else changes too: in Python 2.6 the
> documentation for the csv module explicitly says "If csvfile is a file
> object, it must be opened with the ‘b’ flag on platforms where that
> m
Peter Otten schrieb:
> I'd preprocess the rows as I tend to prefer the simplest approach I can come
> up with. Example:
>
> def recode_rows(rows, source_encoding, target_encoding):
> def recode(field):
> if isinstance(field, unicode):
> return field.encode(target_encoding)
Sibylle Koczian wrote:
> I want to put data from a database into a tab separated text file. This
> looks like a typical application for the csv module, but there is a
> snag: the rows I get from the database module (kinterbasdb in this case)
> contain unicode objects and numbers. And of course the
On Tue, Nov 24, 2009 at 11:42 AM, Sibylle Koczian wrote:
> Hello,
>
> I want to put data from a database into a tab separated text file. This
> looks like a typical application for the csv module, but there is a
> snag: the rows I get from the database module (kinterbasdb in this case)
> contain u
Hello,
I want to put data from a database into a tab separated text file. This
looks like a typical application for the csv module, but there is a
snag: the rows I get from the database module (kinterbasdb in this case)
contain unicode objects and numbers. And of course the unicode objects
contai