From 23e1afb245f66ec91adf29ffd2b035110d5cbd67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=AE=E6=9C=AC=E6=A2=A8=E6=B2=99?= Date: Wed, 14 Jul 2021 19:33:31 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E3=83=A9=E3=83=B3=E3=82=AD=E3=83=B3?= =?UTF-8?q?=E3=82=B0=E3=81=AE=E5=AE=9F=E8=A3=85=E5=AE=8C=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/app.js b/app.js index ad9a93a7..f1c09a12 100644 --- a/app.js +++ b/app.js @@ -1 +1,49 @@ 'use strict'; +const fs = require('fs'); +const readline = require('readline'); +const rs = fs.createReadStream('./popu-pref.csv'); +const rl = readline.createInterface({ input: rs, output: {} }); +const prefectureDataMap = new Map(); // key: 都道府県 value: 集計データのオブジェクト +rl.on('line', lineString => { + const columns = lineString.split(','); + const year = parseInt(columns[0]); + const prefecture = columns[1]; + const popu = parseInt(columns[3]); + if (year === 2010 || year === 2015) { + let value = prefectureDataMap.get(prefecture); + if (!value) { + value = { + popu10: 0, + popu15: 0, + change: null + }; + } + if (year === 2010) { + value.popu10 = popu; + } + if (year === 2015) { + value.popu15 = popu; + } + prefectureDataMap.set(prefecture, value); + } +}); +rl.on('close', () => { + for (let [key, value] of prefectureDataMap) { + value.change = value.popu15 / value.popu10; + } + const rankingArray = Array.from(prefectureDataMap).sort((pair1, pair2) => { + return pair2[1].change - pair1[1].change; + }); + const rankingStrings = rankingArray.map(([key, value]) => { + return ( + key + + ': ' + + value.popu10 + + '=>' + + value.popu15 + + ' 変化率:' + + value.change + ); + }); + console.log(rankingStrings); + }); \ No newline at end of file From 6cc919bb3e41ba5bcc5dbe7b7431114ced1bc004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=AE=E6=9C=AC=E6=A2=A8=E6=B2=99?= Date: Wed, 14 Jul 2021 19:52:58 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=83=A9=E3=83=B3=E3=82=AD=E3=83=B3?= =?UTF-8?q?=E3=82=B0=E9=A0=86=E4=BD=8D=E5=AE=9F=E8=A3=85=E5=AE=8C=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- intro-curriculum-3002 | 1 + 1 file changed, 1 insertion(+) create mode 160000 intro-curriculum-3002 diff --git a/intro-curriculum-3002 b/intro-curriculum-3002 new file mode 160000 index 00000000..097ee46e --- /dev/null +++ b/intro-curriculum-3002 @@ -0,0 +1 @@ +Subproject commit 097ee46e5520e8eac4a650ec7a5331f2cf196553