This is pretty similar to a library I'm actively working on called Papa Parse: http://papaparse.com
This is pretty similar to a library I'm actively working on called Papa Parse: http://papaparse.com
My reason for making this was a mix of "hey let's try making this", let me make something even shorter and (hopefully) sweeter, and "no jQuery".
Your parser is off to a good start: you nailed the general idea of good API design. In other words, it's easy to use, which is immediately appealing. For other things, I think there's been great feedback in the rest of these comments.
(By the way, Papa Parse only uses jQuery for convenience in interacting with the DOM for things like file input elements. The core parser, including the file streamer, is vanilla Javascript.)
"x",""x"",,"x
x","x"
"y",,,,123 [
["x","x\"","","x"],
["x","x"],
["y","","","",123]
]
I can't see anything wrong with it. Am I missing something? [
["x","\"x\"","","x\nx","x"],
["y","","","",123]
]
It's valid CSV, inasmuch as it's accepted and generated by a lot of tools and RFC 4180 ABNF: escaped = DQUOTE *(TEXTDATA / COMMA / CR / LF / 2DQUOTE) DQUOTEThat CSV text is malformed. Arguably, the parsing succeeded, but the expected errors were generated and reported.