-
Notifications
You must be signed in to change notification settings - Fork 270
Open
Description
Hi there, trying to read a CSV file and stream its output data to another JSON array file.
var Converter = require("csvtojson").Converter;
var csvConverter = new Converter({
constructResult: false,
downstreamFormat: "array"
});
var readStream = require("fs").createReadStream(req.file.path);
var writeStream = require("fs").createWriteStream("csvData.json");
readStream
.pipe(csvConverter)
.subscribe((jsonObj, index) => {
jsonObj.myNewKey = "some value";
})
.pipe(writeStream);
But the last JSON added to the array adds an extra comma at the end creating an invalid array/json.
As such:
[
{Name: Bob},
{Name: Sarah},
{Name: James},
]
How could I make sure it doesn't add the comma on the last entry?
Cheers
dwhieb, oliverfoster, mannyvergel, camlegleiter, rami-res-zz and 11 more