comparing dialects of csv-module

Malte Dik malte.usenet at web.de
Sat Dec 19 06:08:19 EST 2009


Hi out there!

I want to put some intelligence into a csv reading script and in order to do 
so I want to compare possible different dialects I collect with some random

d = csv.Sniffer().sniff("1,2,3,4"),

because the csv is kinda dirty.

Now sniff() returns a class object and those aren't comparable in the "if 
dialect_1 == dialect_2: count something" sense.

Has anyone around here already dealt with this kind of problem and maybe 
even a solution I could utilize? That would be great.

If not - I guess I would just write a quick function comparing the 
attributes of those dialects ... - but just out of educational curiosity: 
Would it be the right way to implement an __eq__(...) function into the 
Dialect class or how would someone who would want to make it right do it?


Sincerest greetings,

Malte



More information about the Python-list mailing list