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
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.
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
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