gkindel/CSV-JS — pull request #16 by cygnyx (2014-12-12 05:11:04+00:00)
Title: node stream support idea

I would like to be able to parse very large CSV files in node.js. I've implemented a CSV.stream as an idea on how this might be supported. As a utility function I also implemented CSV.json for some example output. In practice I would use the object stream output from CSV.stream for further processing. I'm not sure how this might work in a web browser. I think there are tools, like browserify, that emulate the node.js type of 'require' function. I've included a command line example in the code which demonstrates a simple case

$ node -e "c=require('CSV-JS');require('fs').createReadStream('csv.txt').pipe(c.stream()).pipe(c.json()).pipe(process.stdout)"

This implementation could be improved, but I didn't want to modify a lot of the existing code. The new code parses the text input stream line by line. It feeds a single line at a time to CSV.parser() and push the result into the output stream.