Add basic risk by age dashboard.
This commit is contained in:
@@ -93,7 +93,7 @@ async function processCombined({ date, zip }, countyInfo, output) {
|
||||
|
||||
async function processSingleZip (zip, countyInfo) {
|
||||
const output = {
|
||||
directory: `./public/data/state/cases/`,
|
||||
directory: `./public/data/overall/cases/`,
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -116,7 +116,7 @@ async function processCombined({ date, zip }, countyInfo, output) {
|
||||
|
||||
async function processSingleZip (zip, countyInfo) {
|
||||
const output = {
|
||||
directory: `./public/data/state/deaths/`,
|
||||
directory: `./public/data/overall/deaths/`,
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -112,7 +112,7 @@ async function processCombined({ date, zip }, countyInfo, output) {
|
||||
|
||||
async function processSingleZip (zip, countyInfo) {
|
||||
const output = {
|
||||
directory: `./public/data/state/hospitalizations/`,
|
||||
directory: `./public/data/overall/hospitalizations/`,
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { getCounty } from '../../util.js'
|
||||
|
||||
async function processSingleZip ({ date, zip }) {
|
||||
const output = {
|
||||
directory: `./public/data/state/testing/by-county/`,
|
||||
directory: `./public/data/overall/testing/by-county/`,
|
||||
file: county => `${county}.json`
|
||||
}
|
||||
|
||||
|
||||
49
data/parser/risk/age.js
Normal file
49
data/parser/risk/age.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import mkdirp from 'mkdirp'
|
||||
import path from 'path'
|
||||
import fsp from 'fs/promises'
|
||||
import Papa from 'papaparse'
|
||||
import { getCounty } from '../../util.js'
|
||||
|
||||
async function processSingleZip ({ date, zip }) {
|
||||
const output = {
|
||||
directory: `./public/data/risk/age/`,
|
||||
file: `age.json`
|
||||
}
|
||||
|
||||
try {
|
||||
await fsp.rm(output.directory, { recursive: true })
|
||||
} catch (e) {}
|
||||
|
||||
const csv = await zip.entryData('epicurve_age_group_rpt_date.csv').then(res => res.toString())
|
||||
|
||||
const rows = Papa.parse(csv, {
|
||||
header: true
|
||||
}).data
|
||||
|
||||
const results = rows.map(row => {
|
||||
return {
|
||||
age_group: row.age_group,
|
||||
report_date: row.report_date,
|
||||
cases: +row.cases,
|
||||
hospitalizations: +row.confirmed_case_hospitalization,
|
||||
deaths: +row.deaths,
|
||||
total_cases: +row.cases_cum,
|
||||
total_deaths: +row.total_deaths
|
||||
}
|
||||
}).filter(row => !!row.report_date)
|
||||
|
||||
const data = {
|
||||
segment: { },
|
||||
headers: Object.keys(results[0]),
|
||||
rows: results.map(row => Object.values(row))
|
||||
}
|
||||
|
||||
await mkdirp(output.directory)
|
||||
await fsp.writeFile(path.join(output.directory, output.file), JSON.stringify(data))
|
||||
}
|
||||
|
||||
function process (zips) {
|
||||
return processSingleZip(zips.at(-1))
|
||||
}
|
||||
|
||||
export default process
|
||||
Reference in New Issue
Block a user