Greetings,
First of all, thank you for the work you are doing on this library.
I have the following CSV file, where the delimiter is a colon : :
I'm now using the tablib library to import it:
tmp = open('test.csv', 'r')
tmp2 = tablib.Dataset().load(tmp, format='csv')
But the file is wrongly parsed, because the csv library did not sniffed the delimiter correctly:
test:test2
-------------
value1:value2
I saw that you are passing 2048 bytes of samples to be sniffed (
|
csv.Sniffer().sniff(stream.read(2048), delimiters=delimiter or cls.DEFAULT_DELIMITER) |
), I now tested to manually sniff the CSV using only the first line:
dialect = csv.Sniffer().sniff(tmp.readline())
The delimiter is now indeed recognized as a colon :.
My question is: shouldn't you pass the first line to sniff only (using readline()) ? Or maybe fallback on the actual behaviour only if the headers is not present in the file ?
Related issue: #502
Regards
Greetings,
First of all, thank you for the work you are doing on this library.
I have the following CSV file, where the delimiter is a colon
::test:test2 value1:value2I'm now using the
tabliblibrary to import it:But the file is wrongly parsed, because the
csvlibrary did not sniffed the delimiter correctly:I saw that you are passing
2048 bytesof samples to be sniffed (tablib/src/tablib/formats/_csv.py
Line 58 in 4bbb35a
The delimiter is now indeed recognized as a colon
:.My question is: shouldn't you pass the first line to sniff only (using
readline()) ? Or maybe fallback on the actual behaviour only if the headers is not present in the file ?Related issue: #502
Regards