21 ms·
Where did you get your inspiration? This is pretty similar to a library I'm actively working on called Papa Parse: http://papaparse.com http://papaparse.com
by mholt 12y ago
Where did you get your inspiration?
This is pretty similar to a library I'm actively working on called Papa Parse: http://papaparse.com http://papaparse.com
- knrz 12y agoIt was actually your library that inspired me :). 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".
- mholt 12y agoOkay, cool. I'm surprised--but pleased--since inspiring others to code is one of my ambitions. 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.)
- gav 12y agoNote that it fails to parse CSV like: "x",""x"",,"x x","x" "y",,,,123
- knrz 12y agoThe previous commit (probably) failed at that. However, with the latest commit, parsing that malformatted CSV returns: [ ["x","x\"","","x"], ["x","x"], ["y","","","",123] ] I can't see anything wrong with it. Am I missing something?
- gav 12y agoIt should parse as: [ ["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) DQUOTE
- mholt 12y ago(Are you talking about Papa, seeing that your comment is a response to mine?) That CSV text is malformed. Arguably, the parsing succeeded, but the expected errors were generated and reported.