4 ms·
Ever heard of jquery-csv? I wrote the jquery-csv over two years ago with the goal of being the first completely RFC compliant CSV parser for Javascript. It in
by EvanPlaice 12y ago
Ever heard of jquery-csv?
I wrote the jquery-csv over two years ago with the goal of being the first completely RFC compliant CSV parser for Javascript.
It integrates with the CSV namespace but doesn't depend on it, uses pure vanilla JS, works with Node.js.
At the very least, if you want to claim RFC compliance you should have a test runner that verifies that your code doesn't break on the edge cases.
https://code.google.com/p/jquery-csv/source/browse/test/test.html https://code.google.com/p/jquery-csv/source/browse/test/test...
Once you have your state machine working, your best bet to optimize speed is by limiting string copy operations. I managed this by using a regex tokenizer that groups any non-terminals (ex data between quotes).
I wrote it with the intent of providing a lib that can effectively parse CSV data from the browser (loaded remotely via AJAX or locally via the HTML5 File API).
The biggest weakness of parsing CSV on the browser is the inability to process data streams. That 2GB memory limit on JS scrips in the browser becomes a fundamental weakness when you're trying to process large CSV files.
CSV in general is terrible for data storage, unless it's only used for serialization because arbitrarily reading any point in the input data stream requires the parser to start from the beginning. You're basically screwed if you can't hold the whole dataset in memory as a 2D array.