npm

Bring the best of OSS JavaScript development to your projects with npm Orgs - private packages & team management tools.Learn more »

skipper-csv

0.0.1 • Public • Published

skipper emblem - face of a ship's captain CSV Parser Adapter

NPM version     Build Status

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

Hossam Hammady

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.

image_squidhome@2x.png

install

npm i skipper-csv

Downloadsweekly downloads

388

version

0.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability