summaryrefslogtreecommitdiff
path: root/client/data.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-10-05 16:36:12 +0200
committerJules Laplace <julescarbon@gmail.com>2018-10-05 16:36:12 +0200
commit852ed2e007deac47292d3e83a374070683c29894 (patch)
treecacff78f2bc63c77cdb458863fc576043561adb1 /client/data.js
parent0ca3983dd9e00a93cc1ed1c55b2ad7a4a6b14bf2 (diff)
inequality client
Diffstat (limited to 'client/data.js')
-rw-r--r--client/data.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/client/data.js b/client/data.js
new file mode 100644
index 0000000..4eab9d3
--- /dev/null
+++ b/client/data.js
@@ -0,0 +1,29 @@
+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 } \ No newline at end of file