4 CSV_URL=https://www.berlin.de/lageso/_assets/gesundheit/publikationen/corona/bezirkstabelle.csv
5 table_path=daily_infections_table.txt
7 # If we don't have a table file yet, we need to provide its header.
8 header=" CW FK Li MH Mi Ne Pa Re Sp SZ TS TK sum"
9 if [ ! -f "${table_path}" ]; then
10 echo "${header}" > "${table_path}"
13 # Parse Lageso day table of new infections by district into new line for history table.
14 today="$(date +%Y-%m-%d)"
16 | awk 'BEGIN { FS=";"; ORS=""; print "'${today}'" }; '\
17 '!/^Bezirk/ { printf "%4d", $3 }; '\
18 'END { printf "\n" }' "${filename}" >> "${table_path}"
20 # Write enhanced table output to directory served by web server.
22 # Use intermediate /tmp/ step so we don't overwrite a valid previous output with
23 # the emptiness delivered to stdout on any error, before such an error would
24 # kill this script due to "set -e".
25 ./enhance_table.py "${table_path}" html > /tmp/berlin_corona.html
26 ./enhance_table.py "${table_path}" txt > /tmp/berlin_corona.txt
27 mv /tmp/berlin_corona.html /var/www/html/
28 mv /tmp/berlin_corona.txt /var/www/html/