Last active
May 4, 2019 03:42
-
-
Save SimplGy/7865d9ef427444f18ebe2578ae2573fb to your computer and use it in GitHub Desktop.
Node - get the contents of all the files in DIR
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
const fs = require('fs') | |
const path = require('path') | |
const DIR = 'input/'; | |
const readFile = name => fs.readFileSync(name); | |
(async () => { | |
const files = fs.readdirSync(DIR) | |
.filter(s => s.match(/\.csv$/)) // only .csv files -- change to whatever you want. | |
.map(name => path.join(DIR, name)) | |
.map(readFile) | |
.map(buffer => buffer.toString()); | |
console.log(files); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment