skipper-csv
v0.0.1
Published
Stream transform Skipper's file uploads to a CSV parser
Downloads
617
Maintainers
Readme
CSV Parser Adapter
CSV Parser adapter for receiving upstreams. Particularly useful for streaming multipart file uploads from the Skipper body parser.
By using this adapter, you can CSV parse the uploaded files in-flight, as soon as first chunks are ready.
You don't have to wait until the upload is finished to start parsing.
You simply configure the adapter by giving it the CSV parse options
(typically those found in csv-parse module).
You also pass rowHandler
function in the options that will be called for every parsed row.
See example usage below.
Acknowledgement
This module is an adaptation of skipper-disk module. Much of the code is borrowed from there.
Installation
$ npm install skipper-csv --save
If you're using this module with Express, Connect, Kraken, or a vanilla Node.js server, make sure you have skipper itself installed as your body parser. This is the default configuration in Sails as of v0.10.
Usage
Basic example
req.file('files').upload({
adapter: require('skipper-csv'),
csvOptions: {delimiter: ',', columns: true},
rowHandler: function(row, fd){
console.log(fd, row);
}
}, function (err, files) {
if (err)
return res.serverError(err);
return res.json({
message: "Uploaded " + files.length + " CSV files!",
files: files
});
});
Testing
To run the tests:
$ npm test
License
MIT © 2016
Data Analytics group
Qatar Computing Research Institute
member of Qatar Foundation
See LICENSE.md
.
This module is part of the Sails framework, and is free and open-source under the MIT License.