summaryrefslogtreecommitdiff
path: root/client/data.js
blob: 15792c963815405c9b8d810ab40c155a84d52abd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const files = [
  "housing-costs-and-income-inequality",
  "income-inequality-over-time",
  "shares-of-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, h, lines, }
  })
})
const allPromises = Promise.all(dataPromises).then(data => {
  return data.reduce((a,b) => { a[b.name]=b, a }, {})
})
const load = () => {
  return allPromises
}

export { load }