CSV Dialect Example Requested - NEWBIE
caldwellinva
caldwellinva at cox.net
Tue Oct 28 06:27:50 EST 2003
Hi!
> I do not have an example, but the first failure in this script is that the
> class in the csv module that you want to use as a base class is
> csv.Dialect (note case). This causes the attribute error you report.
Vince, thank you for pointing this out ... it runs further now, but still
produces an error.
Revised Version
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
Error Message
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 10, in ?
reader = csv.reader(file("c:\\Temp\\test.csv"), dialect=dialect)
File "C:\Python23\lib\csv.py", line 39, in __init__
raise Error, "Dialect did not validate: %s" % ", ".join(errors)
Error: Dialect did not validate: lineterminator not set, quoting parameter
not set
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