X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bdeck_id%7D%7D/cards/%7B%7Bcard_id%7D%7D/feed.xml?a=blobdiff_plain;f=enhance_table.py;h=25fcd08048705eab18309283ec51d39a5d716a91;hb=8b643b326d04387f4903008cbeab89b3a9a6adb7;hp=0482bdfbffbf8fe0e89bb174454b04f561318a92;hpb=5252dee46a33cce9616ba4e4103b59dba2ec44c1;p=berlin-corona-table
diff --git a/enhance_table.py b/enhance_table.py
index 0482bdf..25fcd08 100755
--- a/enhance_table.py
+++ b/enhance_table.py
@@ -32,6 +32,9 @@ translate = {
'TS': 'Tempelhof-Schöneberg',
'TK': 'Treptow-Köpenick',
'sum': 'all of Berlin',
+ 'wsum': 'sum for last 7 days',
+ 'wavg': 'per-day average of new infections for last 7 days',
+ 'winc': 'incidence (x per 100k inhabitants) of new infections for last 7 days',
}
# Read infections table path and output type.
@@ -128,23 +131,53 @@ for i in range(len(sorted_dates)):
# Optimized for web browser viewing.
if output_type == 'html':
- print('')
- print('')
- print('
')
- print('')
- print('date | ')
+ print("""
+
+
+
+Berlin's Corona infection numbers, development by districts
+
+home · contact · privacy
+Berlin's Corona infection numbers, development by districts
+Updated daily at 9pm based on data from the "Senatsverwaltung für Gesundheit, Pflege und Gleichstellung". Source code. Text view optimized for terminal curl.
+
+
+ | """)
+ sorted_dates.reverse()
+ long_wsum = translate['wsum']
+ long_wavg = translate['wavg']
+ long_winc = translate['winc']
+ sum_district = sorted_districts[-1]
for district in sorted_districts:
- print('%s | ' % district)
+ long_form = translate[district]
+ # Wrap in div because the vertical orientation otherwise fails
+ # in Chromium.
+ print(' | ' % long_form)
+ print('
')
+ print('')
+ # In Chromium, the th only stay fixed if also given this class.
+ print('date | ')
+ print(' | ')
+ for district in sorted_districts:
+ print('%s | ' % district)
print('
')
- sorted_dates.reverse()
for date in sorted_dates:
- print('')
+ print('
')
print('%s | ' % date)
+ print('')
+ print('+ | ')
+ print('Σ | ' % long_wsum)
+ print('Ã | ' % long_wavg)
+ print('i | ' % long_winc)
+ print(' | ')
for district in sorted_districts:
district_data = db[district][date]
- week_sum = week_avg = week_inc = ''
+ week_sum = week_avg = week_inc = '?'
new_infections = district_data['new_infections']
if 'week_sum' in district_data:
week_sum = '%s' % district_data['week_sum']
@@ -154,10 +187,10 @@ if output_type == 'html':
week_inc = '%.1f' % district_data['week_incidence']
print('')
print('')
- print('new | %s | ' % new_infections)
- print('wsum | %s | ' % week_sum)
- print('wavg | %s | ' % week_avg)
- print('winc | %s | ' % week_inc)
+ print('%s | ' % new_infections)
+ print('%s | ' % week_sum)
+ print('%s | ' % week_avg)
+ print('%s | ' % week_inc)
print(' ')
print(' | ')
print('
')
@@ -170,17 +203,16 @@ elif output_type == 'txt':
# Explain what this is.
intro = \
"""Table of Berlin's Corona infection number development by districts.
-Updated daily around 9pm.
+Updated daily at 9pm based on data from the "Senatsverwaltung für Gesundheit, Pflege und Gleichstellung".
Abbrevations/explanations:
"""
for k in translate:
intro += "%s: %s\n" % (k, translate[k])
- intro += """wsum: sum for last 7 days
-wavg: per-day average of new infections for last 7 days
-winc: incidence (x per 100k inhabitants) of new infections for last 7 days
-
+ intro += """
Source code: https://plomlompom.com/repos/?p=berlin-corona-table
+
+HTML view: https://plomlompom.com/berlin_corona.html
"""
print(intro)