From ed5f52126c09c141005fe2bca9110e7337c5e721 Mon Sep 17 00:00:00 2001 From: kishorsharma Date: Tue, 17 May 2016 00:36:13 +0530 Subject: [PATCH 1/2] Adding empty string check. #15 --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 087f1b4..083c45c 100755 --- a/index.js +++ b/index.js @@ -38,7 +38,7 @@ module.exports = function (options) { var _data = {} for(var k in data) { var value = data[k].trim() - _data[k.trim()] = isNaN(value) ? value : +value + _data[k.trim()] = (isNaN(value) || value === '') ? value : +value; } this.queue(_data) })) From 05adeff80d43cf84b6341c2862232e9ce78a36f3 Mon Sep 17 00:00:00 2001 From: kishorsharma Date: Tue, 28 Jun 2016 12:22:50 +0000 Subject: [PATCH 2/2] Replacing csv-stream with fast-csv as values with comma were not correctly parsed by former. --- index.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 083c45c..b2464c9 100755 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ var path = require('path') var chpro = require('child_process') var through = require('through') -var csv = require('csv-stream') +var csv = require('fast-csv') var osenv = require('osenv') var duplexer = require('duplexer') var concat = require('concat-stream') @@ -33,7 +33,7 @@ module.exports = function (options) { var write = fs.createWriteStream(filename) .on('close', function () { var child = spawn(require.resolve('j/bin/j.njs'), spawnArgs) - child.stdout.pipe(csv.createStream(options)) + child.stdout.pipe(csv(options)) .pipe(through(function (data) { var _data = {} for(var k in data) { diff --git a/package.json b/package.json index 62ea2fe..d88f0d8 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "dependencies": { "JSONStream": "^1.0.4", "concat-stream": "^1.4.6", - "csv-stream": "~0.1.3", "duplexer": "~0.1.1", + "fast-csv": "^2.0.0", "j": "^0.4.3", "minimist": "^1.1.1", "osenv": "^0.1.3",