csv module

2005-12-28 Thread Laurent Laporte
hello, I'm using cvs standard module under Python 2.3 / 2.4 to write a file delimited with tabs. I use the "excel-tab" dialect to do that. To read my CSV file, I choose to 'sniff' with a sample data in order to get the dialect. The problem I meet is that I get a wrong dialect: the sniffer return

csv.Sniffer: wrong detection of the end of line delimiter

2005-12-28 Thread Laurent Laporte
hello, I'm using cvs standard module under Python 2.3 / 2.4 to read a CSV file. The file is opened in binary mode, so I keep the end of line terminator. It appears that the csv.Sniffer force the line terminator to be '\r\n'. It's fine under Windows but wrong under Linux or Macintosh. More about

Re: csv module

2005-12-28 Thread Laurent Laporte
Sorry, Here is my example: Python 2.3.1 (#1, Sep 29 2003, 15:42:58) [GCC 2.96 2731 (Red Hat Linux 7.1 2.96-98)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import csv >>> t_sniffer = csv.Sniffer() >>> t_data = "aaa\tbbb\r\n\r\nAAA\tBBB\r\n" >>> t_diale

Re: csv module

2005-12-28 Thread Laurent Laporte
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_