donfanning
8/15/2018 - 1:20 PM

counts the number of lines in files to big to open with text editors

counts the number of lines in files to big to open with text editors

var fileName = "deleteProducts.xml"; //change this line
var fs = require('fs');
var LineByLineReader = require('line-by-line');
var lineCount = 0;
lrInner = new LineByLineReader(fileName);
lrInner.on('error', function(err) {
    // 'err' contains error object
    console.log(err);
});
lrInner.on('line', function(lineInner) {
    lrInner.pause();
    lineCount++;
    lrInner.resume();
});
lrInner.on('end', function() {
    console.log(lineCount);
});