tail-stream module in nodejs is not printing last

2020-05-05 00:47发布

I am using tail-stream to get data from a csv file and converting each csv record to json format and printing it.

But tail-stream is not printing the last line of the file it is keeping it as a buffer, and if I update the file all the rows from previous last(the buffered last row) row to updated last row(excluding last row) are printed, its again storing the latest last row in buffer

So is this the behavior of the tail-stream or is there any wrong in my code

https://www.npmjs.com/package/tail-stream

My code:

var tailStream      = require('tail-stream');
var Converter       = require("csvtojson").Converter;
var converter  = new Converter({constructResult:false});

var logStream = tailStream.createReadStream('issue_Approver_Rohit1.csv', {
    beginAt: 0,
    onMove: 'follow',
    detectTruncate: false,
    onTruncate: 'end',
    endOnError: false
});


logStream.pipe(converter);


converter.on("record_parsed", function (jsonObj) {
        console.log(jsonObj); //here is your result json object

    });

});

0条回答
登录 后发表回答