X-Git-Url: https://plomlompom.com/repos/?p=berlin-corona-table;a=blobdiff_plain;f=update.sh;h=57ecf89d056395bf704c3ead01f945d118c7a597;hp=1a84c8ba9fa70208f7c7693d151b52c03be487ca;hb=f91a74c7aa31a742e50629e4e57736cf5192320d;hpb=74f4868304347258087e64ad210d5e8a0902b092 diff --git a/update.sh b/update.sh index 1a84c8b..57ecf89 100755 --- a/update.sh +++ b/update.sh @@ -1,11 +1,22 @@ #!/bin/sh +set -e -# Parse Lageso day table of new infections by district into new line for history table. +CSV_URL=https://www.berlin.de/lageso/_assets/gesundheit/publikationen/corona/bezirkstabelle.csv +table_path=daily_infections_table.txt + +# If we don't have a table file yet, we need to provide its header. +header=" CW FK Li MH Mi Ne Pa Re Sp SZ TS TK sum" +if [ ! -f "${table_path}" ]; then + echo "${header}" > "${table_path}" +fi + +# Parse Lageso day table of new infections by district into new line for history table. today="$(date +%Y-%m-%d)" -curl https://www.berlin.de/lageso/_assets/gesundheit/publikationen/corona/bezirkstabelle.csv \ +curl "${CSV_URL}" \ | awk 'BEGIN { FS=";"; ORS=""; print "'${today}'" }; '\ '!/^Bezirk/ { printf "%4d", $3 }; '\ -'END { printf "\n" }' "${filename}" >> /home/plom/berlin-corona-table/daily_infections_table.txt +'END { printf "\n" }' "${filename}" >> "${table_path}" # Write enhanced table output to directory served by web server. -./enhance_table.py > /var/www/html/berlin_corona.txt +./enhance_table.py "${table_path}" txt > /var/www/html/berlin_corona.txt +./enhance_table.py "${table_path}" html > /var/www/html/berlin_corona.html