Created
March 22, 2020 19:51
-
-
Save mariotti/1484aa4d6ade8f27fc647785ee8000c8 to your computer and use it in GitHub Desktop.
Simple get pro mille on population from COVID-19 data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# To run this you will need to do first: | |
# 1) Get the data | |
# git clone https://github.com/CSSEGISandData/COVID-19; cd COVID-19 | |
# 2) Run this script | |
# 3) Optionally plot them ... example for gnuplot at the end | |
# | |
# countriesPop="Switzerland:8570 Italy:60480 Spain:46660 Germany:82790 France:66990" | |
# Does not for all countries, for example France has "states" | |
# | |
countriesPop="Switzerland:8570 Italy:60480 Spain:46660 Germany:82790" | |
# The total population here comes from a simple google search "<country> population" and it used on a /1000 base. | |
# | |
for cp in $countriesPop; | |
do | |
cc=$(cut -d':' -f1 <<<${cp}) | |
pp=$(cut -d':' -f2 <<<${cp}) | |
cat csse_covid_19_data/csse_covid_19_daily_reports/*.csv | grep $cc | tail -26 | awk -v cc=${cc} -v pp=${pp} -F ',' '{printf("%s,%s,%s,%s,%s,%s,%s,%s\n",cc,$4,$4/pp,$5,$5/pp,$6,$6/pp,($6/$4)*100.0);}' | tee percent_pop.out | |
cat percent_pop.out | grep $cc | sed "s/${cc}.//" | nl -s, | sed 's/,/ /g' > percent_pop.${cc}.out | |
done | |
# | |
# | |
# Example gnuplot | |
# plot 'percent_pop.Italy.out' using 1:3 with linespoints title "IT", 'percent_pop.Switzerland.out' using 1:3 with linespoints title "CH", 'percent_pop.Spain.out' using 1:3 with linespoints title "ES", 'percent_pop.Germany.out' using 1:3 with linespoints title "DE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment