summaryrefslogtreecommitdiff
path: root/client/data.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-08-12 15:16:16 +0200
committerJules Laplace <julescarbon@gmail.com>2018-08-12 15:16:16 +0200
commit86213c887b101044ae2f3ea393fee927842dbde2 (patch)
tree72e903084c6f19eb8f15640c1d354b9226dea591 /client/data.js
inequality sonification project
Diffstat (limited to 'client/data.js')
-rw-r--r--client/data.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/client/data.js b/client/data.js
new file mode 100644
index 0000000..15792c9
--- /dev/null
+++ b/client/data.js
@@ -0,0 +1,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 } \ No newline at end of file