home · contact · privacy
f1b74677156a796631ca10086f2ec2ff87378ca5
[berlin-corona-table] / update.sh
1 #!/bin/sh
2 set -e
3
4 CSV_URL=https://www.berlin.de/lageso/_assets/gesundheit/publikationen/corona/bezirkstabelle.csv 
5 table_path=/home/plom/berlin-corona-table/daily_infections_table.txt
6
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}"
11 fi
12
13 # Parse Lageso day table of new infections by district into new line for history table. 
14 today="$(date +%Y-%m-%d)"
15 curl "${CSV_URL}" \
16 | awk 'BEGIN { FS=";"; ORS=""; print "'${today}'" }; '\
17 '!/^Bezirk/ { printf "%4d", $3 }; '\
18 'END { printf "\n" }' "${filename}" >> "${table_path}" 
19
20 # Write enhanced table output to directory served by web server.
21 ./enhance_table.py > /var/www/html/berlin_corona.txt