rs2csv

Generate a CSV (comma-separated values) from a recordset like array

rs2csv

Generate a CSV (Comma-separated values) output format from a RecordSet, for data exports and more, because your boss loves exel.

Install

$ npm install rs2csv
$ git clone https://github.com/exos/rs2csv.git
$ cd rs2csv
$ npm install -d

Use

var rs2csv = require('rs2csv');
 
// And rest 
 
db.query("SELECT * FROM Products", function (errresults) {
 
    // ... 
 
    rs2csv.parse(results, function (errcsvContent) {
        // You happy 
    });
 
});
 
var rs2csv = require('rs2csv');
 
// And rest 
 
db.query("SELECT * FROM Products", function (errresults) {
 
    // ... 
 
    rs2csv.saveToFile(results, 'products.csv', function (errcsvContent) {
        // You happy 
    });
 
});
 
var rs2csv = require('rs2csv');
 
// And rest 
 
 
app.get('/report', function (reqres) {
 
    // ... 
 
    db.query("SELECT * FROM Products", function (errresults) {
        var csvStream = rs2csv.createStream(results);
        csvStream.pipe(res);
    });
 
});
 

Documentation

https://github.com/exos/rs2csv/wiki/Documentation

License

GPL2