const files = [ // "gun_violence", "mass_shootings_from_columbine", "firearms_manufactured", "ar_15_2016_18", ] const parse = require('csv-parse') const dataPromises = files.map(name => { return fetch('./data/' + name + '.csv').then(rows => { return rows.text() }).then(text => { return new Promise((resolve, reject) => { parse(text, {}, (_, lines) => resolve(lines)) }) }).then(lines => { // console.log(name, lines) const h = lines.shift() return { name, h, lines: lines.filter(s => !!s) } }) }) const allPromises = Promise.all(dataPromises).then(data => { return data.reduce((a,b) => { // console.log(b) a[b.name] = b return a }, {}) }) const load = () => { return allPromises } export { load }