On 1 May 2018, at 6:43pm, Peter Da Silva<peter.dasi...@flightaware.com>  wrote:

CSV is an interchange format, it's for software to communicate with other 
software, so the syntax needs to be independent of the locale since you don't 
know if the sender and recipient are in the same locale. Field separator is 
syntax, so the locale settings should not have any effect on it.

That is a very bold and idealistic claim. Not even the person who wrote the currently used CSV standard (RFC4180 anyway) claims such things - in fact he is very quick to point out that it isn't a standard but more of a "commonly used format" which did not have official documentation and so he decided to write up some.  But I am on your side of this war - I feel it "should" be standard, it's just that since it isn't a standard, it's hard to lord it over others doing differently.

There have been very many custom implementations (complete with documentation) for many of the CSV formats around, but it never really progressed to a standard - which is why I assume so much trouble exists.

Probably my favourite line from RFC4180 is to Implementors: "be conservative in what you do, be liberal in what you accept from others".


While on the subject, when I was doing the converter mentioned earlier, I had researched the CSV thing trying to figure out a rule-book (with very little success), but I did make this little test CSV file handy to push through all the CSV importers/readers to see who does it how.

I managed to find it now again and thought I would post it for fun. I have a result set that is correct according to RFC4180 (and yes, SQLite gets it right) but as a fun exercise to the reader, put this text in a file named something.csv and open it in some CSV readers.

For more fun, try to predict the outcome before starting.

What I have found is that there are nearly as many differences in the interpretation as there are CSV interpreters.


csv file--------------------------------------------------------------
Item,Value1, Value 2
1,This is a non-quoted string.,"This is a ""quoted"" one"
2,"This contains a comma ',' and some single quotes.",This one doesn't
3,"Magic disappearing value after quoted value" This text should be hidden, This text must be visible.
4,"This is all on one line","This string goes
over
3 lines."
5, "The value to my right is empty, see how Excel gets this wrong!",
6, The,End
eof--------------------------------------------------------------

PS: According to the RFC, the last record of the last row may or may not contain an ending <CRLF>. I always add one since it makes appending the file easier later.

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to