On 21 May 2019, at 2:38pm, Patrick Sherrill <[email protected]> wrote:
> I don’t know about ‘valid’ csv, it has been a moving target for decades. > White space as far as my recollection should not be considered in parsing a > csv. You can do it, but you have to be consistent. There is a problem with this specific line: somestuff, "some,stuff" CSV files are expected to come in two different format. One is to have double-quotes around all text values: "somestuff", "some,stuff" In this form, the comma is just, and obviously, a separator. Blank space around separators is not a problem and parsers can identify it and ignore it as required. The other commonly-found CSV format is this: somestuff, otherstuff In this format, strings are not indicated with the use of double quotes. In this case the separator is a comma. Space characters around it are not blank space, they're part of the value. Because if they aren't there's no way to supply a string that begins or ends with a space. So the second value parsed from this line starts with a space character. Given those two possibilities, How would you expect a parser to figure out this line ? somestuff, "some,stuff" It's neither one format nor the other. Parsers might handle this however they want. It is permitted for a parser to look at the first character, decide that the line starts with a string with no delimiter, and identify the three strings on that line as somestuff "some <-- this value begins with <space><double-quote> stuff" <-- this value ends with <double-quote> If you need include commas in your strings, delimit all your strings with double quotes and the problem will go away. _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

