[Csv] Re: [PEP305] Python 2.3: a small change request in CSV module

Skip Montanaro skip at pobox.com
Sun May 18 00:21:38 CEST 2003


    Bernard> *now* there's something else Skip got me thinking about (maybe
    Bernard> this should be a separate post). He rightly underlined that
    Bernard> there's no guarantee that the sniffer will guess right. For
    Bernard> example if most of your fields are "dd/mm/yy" dates, the
    Bernard> sniffer may decide (untried) that '/' is the most likely
    Bernard> delimiter. Hence let me re-iterate my suggestion to tip the
    Bernard> sniffer off by adding a second argument to Sniffer().sniff(),
    Bernard> an optional string holding the allowed or expected
    Bernard> delimiters. Short of direct support for mutiple separators,
    Bernard> which may be too rarely needed to move to the C implementation,
    Bernard> it would be *very* useful to have a means to assist the sniffer
    Bernard> in guessing right.

Please try the attached context diff.  It seems to work as I interpreted
your request.  Note the new test_delimiters method.  When I first wrote it I
guessed wrong what the sniffer would come up with as an unguided delimiter.
It picked '0' instead of '/' as I thought.  With the delimiters parameter it
correctly picks from the string passed in.

Skip

-------------- next part --------------
A non-text attachment was scrubbed...
Name: csv.diff
Type: application/octet-stream
Size: 5232 bytes
Desc: not available
Url : http://mail.python.org/pipermail/csv/attachments/20030517/c2daffea/attachment.obj 


More information about the Csv mailing list