Reputation: 1234
I cant seem to figure out why I'm getting this error with my stream pipeline. I think I have exhausted all paths, so is there something Im missing: Here is what I have:
var myCsvStream = fs.createReadStream('csv_files/myCSVFile.csv');
var csv = require('fast-csv');
var myData = [];
var myFuncs = {
parseCsvFile: function (filepath) {
var csvStream;
csvStream = csv
.parse({headers: true, objectMode: true, trim: true})
.on('data', function (data) {
myData.push(data);
})
.on('end', function () {
console.log('done parsing counties')
});
return csvStream;
}
}
myCsvStream
.pipe(myFuncs.parseCsvFile())
.pipe(process.stdout);
The process.stdout
is just so I can see that the data can continue on to the next stream, however, when adding pipe(process.stdout)
or even a through2
duplex stream I get this maximum callstack reached error. Any Ideas?
Upvotes: 5
Views: 1245
Reputation: 3940
I think you should write it that way :
var myCsvStream = fs.createReadStream('csv_files/myCSVFile.csv');
var csv = require('fast-csv');
var csvStream = csv
.parse({headers: true, objectMode: true, trim: true})
.on('data', function (data) {
myData.push(data);
})
.on('end', function () {
console.log('done parsing counties')
});
myCsvStream
.pipe(csvStream)
.pipe(process.stdout);
After you can wrap it all up in a function.
Upvotes: 1