home · contact · privacy
Turn scrape.py output into daily infections table order format.
[berlin-corona-table] / update.sh
index 57ecf89d056395bf704c3ead01f945d118c7a597..008f716e732607204655ffd7e0529d44b21e99c0 100755 (executable)
--- a/update.sh
+++ b/update.sh
@@ -14,9 +14,15 @@ fi
 today="$(date +%Y-%m-%d)"
 curl "${CSV_URL}" \
 | awk 'BEGIN { FS=";"; ORS=""; print "'${today}'" }; '\
-'!/^Bezirk/ { printf "%4d", $3 }; '\
+'!/^"Bezirk"/ { printf "%4d", $3 }; '\
 'END { printf "\n" }' "${filename}" >> "${table_path}"
 
 # Write enhanced table output to directory served by web server.
-./enhance_table.py "${table_path}" txt > /var/www/html/berlin_corona.txt
-./enhance_table.py "${table_path}" html > /var/www/html/berlin_corona.html
+#
+# Use intermediate /tmp/ step so we don't overwrite a valid previous output with
+# the emptiness delivered to stdout on any error, before such an error would
+# kill this script due to "set -e".
+./enhance_table.py "${table_path}" html > /tmp/berlin_corona.html
+./enhance_table.py "${table_path}" txt > /tmp/berlin_corona.txt
+mv /tmp/berlin_corona.html /var/www/html/
+mv /tmp/berlin_corona.txt /var/www/html/