Created
November 26, 2018 21:02
-
-
Save nojvek/b03f01f0d05d934de6f897ff465605ff to your computer and use it in GitHub Desktop.
Count lines by file extension and path and output csv ready to be sql-analyzed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-env node */ | |
const fs = require(`fs`); | |
const path = require(`path`); | |
const filePaths = fs.readFileSync(`${__dirname}/file_list.txt`, `utf-8`).trim().split(`\n`); | |
console.log(`Total files`, filePaths.length); | |
for (let i = 0, len = filePaths.length; i < len; ++i) { | |
const filePath = filePaths[i]; | |
let lines = null; | |
try { | |
lines = fs.readFileSync(filePath, `utf-8`).split(`\n`).filter(l => /\w/.test(l)); | |
} catch (e) {} | |
if (lines) { | |
console.log(`${filePath}, ${path.extname(filePath)}, ${lines.length}`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment