Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Node - get the contents of all the files in DIR
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(buffer => buffer.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment