Python CSV DictWriter Problems

G

Gabriel Cooper

Is there a known-bug in csv.DictWriter? It is ignoring my attempts to
specify a Dialect. It doesn't even error if you give it anything
invalid. I can send it the registered string-name of the dialect, a
string of gibberish, a dialect object instance, a dialect class
object... it accepts all and ignores all.

Take for example a default-created Dialect, excel-tab:

Python 2.3.3 (#1, Apr 14 2004, 01:02:50)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import csv
>>> csv.list_dialects() ['excel-tab', 'excel']
>>> csv.excel_tab.delimiter '\t'
>>> a =
csv.DictWriter(open('/root/quickbooks/testout.iif','w'),['a','b'],"excel-tab")
csv.DictWriter(open('/root/quickbooks/testout.iif','w'),['a','b'],csv.excel_tab())
csv.DictWriter(open('/root/quickbooks/testout.iif','w'),['a','b'],"no
one is listening")csv.DictWriter(open('/root/quickbooks/testout.iif','w'),['a','b'],csv.excel_tab)
Traceback (most recent call last):

Currently I have to go through and manually set each of the dialect's
attributes individually, like so:(etc.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top