This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: csv.writer refuses a variable parameter
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: skip.montanaro Nosy List: balthus, skip.montanaro
Priority: normal Keywords:

Created on 2004-05-18 21:12 by balthus, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg20836 - (view) Author: Xavier Bassery (balthus) Date: 2004-05-18 21:12
Hi, 
I've reproduced that bug on both the win client and the
cygwin build (windows 2000).

When i do a call on writer like this :
cvsWriter = csv.writer(pseudoFichier, 'excel',
delimiter=delimiteur)

with delimiteur being a variable == ';' ,
       pseudoFichier : a cStringIO

I get that error message :

    cvsWriter = csv.writer(pseudoFichier, 'excel',
delimiter=delimiteur)
TypeError: bad argument type for built-in operation

A way to fix it is to replace the variable delimiteur
with it's value, so 

cvsWriter = csv.writer(pseudoFichier, 'excel',
delimiter=';')

works like a bliss !

I've tried to look at the source of csv.py just to see
that the method that i wanted to see is imported from a
c library (_csv.lib).
I'm not strong enough to look further.
I hope someone here will be able to find the reason of
what seems to be a bug.

Greetings,
Xavier
msg20837 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2004-05-19 01:55
Logged In: YES 
user_id=44345

I can't reproduce the problem:

>>> import csv
>>> import cStringIO
>>> pseudoFichier = cStringIO.StringIO()
>>> delimiteur = ';'
>>> writer = csv.writer(pseudoFichier, 'excel', 
delimiter=delimiteur)
>>> writer.writerow([1,2,3,4])
>>> pseudoFichier.getvalue()
'1;2;3;4\r\n'
History
Date User Action Args
2022-04-11 14:56:04adminsetgithub: 40266
2004-05-18 21:12:00balthuscreate