csv module

Laurent Laporte laurentlaporte at yahoo.com
Wed Dec 28 08:50:53 EST 2005


In fact, there is another bug:

In my CVS file, all the records ends with a trailing tab '\t'
except the header because the last field is always empty.

For example, I get :
>>> import csv
>>> t_sniffer = csv.Sniffer()
>>> t_data = "aaa\tbbb\r\nAAA\t\r\nBBB\t\r\n"
>>> t_dialect = t_sniffer.sniff(t_data)
>>> t_dialect.delimiter
''

It is done in the _guess_delimiter() method during the building of
frequency tables. A striping is done for each line (why??)
If I change:
  freq = line.strip().count(char)
by:
  freq = line.count(char)
It works fine.

Do you have a workaround for that?

------- Laurent.




More information about the Python-list mailing list