Skip to content

Instantly share code, notes, and snippets.

@spinscale
Created January 27, 2021 09:03
Show Gist options
  • Select an option

  • Save spinscale/7bb467a60c5e883abe42ea8bbdf2faff to your computer and use it in GitHub Desktop.

Select an option

Save spinscale/7bb467a60c5e883abe42ea8bbdf2faff to your computer and use it in GitHub Desktop.

Revisions

  1. spinscale created this gist Jan 27, 2021.
    29 changes: 29 additions & 0 deletions calculate-vaccinations.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    #!/bin/bash

    # retrieve URL
    url="https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Impfquotenmonitoring.xlsx?__blob=publicationFile"
    wget -o /dev/null $url -O out.xlsx

    # convert to csv
    # run 'pip3 install xlsx2csv' (or maybe pip depending on your python installation)
    xlsx2csv -a out.xlsx out.csv

    # figure out the number of days we got vaccination data
    # exclude those with no vaccination happening
    days=$(grep -c '^[01][0-9].*,[1-9]\d*,\d*,\d*' out.csv/Impfungen_proTag.csv)

    # extract the total number of vaccinations
    total_first_vaccinations=$(grep ^Gesamt, out.csv/Impfungen_proTag.csv| cut -d',' -f2)

    # average vaccinations per day so far, multiply with 1.0 to get floats
    average_vaccinations_per_day=$(echo "scale=2;$total_first_vaccinations/$days" | bc -l)

    # figure out how many days we need to wait for everyone to be vaccinated
    population=83000000

    days=$(echo "scale=0;$population/$average_vaccinations_per_day" | bc)
    years=$(echo "scale=2;$days/365.0" | bc)

    RED='\033[0;31m'
    NC='\033[0m'
    echo -e "Days until full vaccination: ${RED}$days${NC} (aka ${RED}$years${NC} years)"