Skip to content

Instantly share code, notes, and snippets.

@Xsmael
Created October 12, 2018 12:47
Show Gist options
  • Save Xsmael/af33f51ade9b2a53928da4cd137a7515 to your computer and use it in GitHub Desktop.
Save Xsmael/af33f51ade9b2a53928da4cd137a7515 to your computer and use it in GitHub Desktop.
Count the total number of lines of xls exel files in directory
var fs= require("fs");
var node_xj = require("xls-to-json");
var totalLines= 0;
fs.readdir('./FTA', function (err, files) {
files.forEach((file,idx) => {
console.log(file);
node_xj({
input: './FTA/'+file, // input xls
output: null // output json
}, function(err, result) {
if(err) {
console.error(err);
} else {
let lines= result.length -1;
totalLines+= lines; // to not count the header.
console.error(file+": "+lines+ " lines");
if(idx == files.length-1 ) console.error(" "+totalLines);
}
});
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment