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