const files = [ "housing-costs-and-income-inequality", "income-inequality-over-time", "shares-of-wealth", "weekly-earnings", "household-wealth", ] const dataPromises = files.map(name => { return fetch('./data/' + name + '.csv').then(rows => { return rows.text() }).then(text => { let lines = text.split('\n').map(line => line.split(',')) const h = lines.shift() return { name: name.replace(/-/g, ' '), h, lines: lines.filter(s => !!s) } }) }) const allPromises = Promise.all(dataPromises).then(data => { return data.reduce((a,b) => { a[b.name.replace(/-/g, '_')] = b; return a }, {}) }) const load = () => { return allPromises } export { load }