CSV Dialect Example Requested - NEWBIE

caldwellinva caldwellinva at cox.net
Tue Oct 28 05:41:49 EST 2003


Hi!

** CSV Dialect Example Requested  - NEWBIE **

I would like to use the CSV module and would like to see a working example
that uses a custom dialect.  I have tried the following example from an
earlier posting to the group

import csv

import csv
class dialect(csv.dialect):
    delimiter = '|'
    skipinitialspace = True
    quotechar = '"'
    doublequote = True

reader = csv.reader(file("c:\\Temp\\test.csv"), dialect=dialect)
for row in reader:
     print row

and get the following error

Traceback (most recent call last):
  File
"C:\Python23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py",
line 310, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\Python23\DougSource\test_csv.py", line 4, in ?
    #    delimeter = '|'
AttributeError: 'module' object has no attribute 'dialect'

If the example could show the process for registering a name, that would be
helpful as well.

Thank you,

Doug Caldwell
5533 Dunsmore Road
Alexandria, VA  22315

caldwellinva at cox.net
703-922-8725






More information about the Python-list mailing list