Re: comparing dialects of csv-module

2009-12-20 Thread Malte Dik
quote: d = csv.Sniffer().sniff("1,2,3") def eq(a, b, attributes=[name for name in dir(d) if not > name.startswith("_")]): > ... return all(getattr(a, n, None) == getattr(b, n, None) for n in > attributes) Only change I made is substituting "dir(csv.excel)" or "dir(csv.Dialect)" for

Re: comparing dialects of csv-module

2009-12-19 Thread Malte Dik
quote: > An implementation for the lazy > import csv d = csv.Sniffer().sniff("1,2,3") def eq(a, b, attributes=[name for name in dir(d) if not > name.startswith("_")]): > ... return all(getattr(a, n, None) == getattr(b, n, None) for n in > attributes) > ... Wow, this is awesome.

Re: comparing dialects of csv-module

2009-12-19 Thread Peter Otten
Malte Dik wrote: > 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

comparing dialects of csv-module

2009-12-19 Thread Malte Dik
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 compara