[Csv] Sniffer empty delimiter

skip at pobox.com skip at pobox.com
Wed Dec 28 17:15:25 CET 2005


In this bug report:

    http://python.org/sf/1157169

Neil Schemenauer reports a problem with this code:

    >>> d = csv.Sniffer().sniff('abc', ['\t', ','])
    >>> csv.reader(['abc'], d) 
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    TypeError: bad argument type for built-in operation

In his Sniffer case it is clear that neither TAB nor comma are an explicit
delimiter.  It's also not clear what the delimiter is.  The generated
dialect has a resulting empty delimiter.  I can see three possible remedies:

    1. raise csv.Error from Sniffer.sniff

    2. return comma as the "standard" delimiter or because the sample
       appears to only have a single comma

    3. return TAB as it's first in the delimiters list.

I't sure there are other candidates ("b" because it separates "a" and "c"?)

Any thoughts about the best "remedy" to this problem?  It's clear that
letting the empty delimiter escape into the wild is a problem.

Skip



More information about the Csv mailing list