5 ms·
"What does “malformed” mean? The good/bad thing about CSV is that virtually every text file is valid! The only malformation I can think of is an open quote with
by btilly 7y ago
"What does “malformed” mean? The good/bad thing about CSV is that virtually every text file is valid! The only malformation I can think of is an open quote with no matching close quote (so the entire rest of the document is one value). My implementation is streaming, so there’s no great way to flag it: any future data could have the other quote!*
An example of improper csv code is this:
hello,world,"And this, contains "bad quotes"...",1,2,3
Lest you think this is made up, I ran across this when someone cut and paste Excel into a text field.
I also have seen batch processing of user files break hard when a quote issue like this caused a hand-rolled CSV parser to conclude that half the file was a single very long field.