X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=enhance_table.py;h=4a060a4b758a654ee5593662cf0f66386e037bf1;hb=fca28d3ad3def405de5853c253e0ef130eb41fdc;hp=f8add4efe2bcfaca4989785621323042b0f22982;hpb=671f45cc4eb274e3d102bce10985134988003323;p=berlin-corona-table diff --git a/enhance_table.py b/enhance_table.py index f8add4e..4a060a4 100755 --- a/enhance_table.py +++ b/enhance_table.py @@ -95,13 +95,13 @@ for line in lines[1:]: db[district][date] = {'new_infections': int(district_data)} sorted_dates.sort() -# Define and move sum_district from end to start. +# In LaGeSo's data, the last "district" is actually the sum of all districts / +# the whole of Berlin. For our district order, move it in front of the other +# districts, as its numbers are the most interesting, so in the table views +# we want to see it first. sum_district = sorted_districts.pop() sorted_districts.insert(0, sum_district) -# In LaGeSo's data, the last "district" is actually the sum of all districts / -# the whole of Berlin. -# # Fail on any day where the "sum" district's new infections are not the proper # sum of the individual districts new infections. Yes, sometimes Lageso sends # data that is troubled in this way. It will then have to be fixed manually in @@ -140,16 +140,15 @@ if output_type == 'html': 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.

+

Updated daily at 9pm based on data from the "Senatsverwaltung für Gesundheit, Pflege und Gleichstellung". Source code. Plain text view (optimized for terminal curl).

""") @@ -160,15 +159,16 @@ th { text-align: left; vertical-align: bottom; } print('' % translate[district]) print('') - print('') - # In Chromium, the th only stay fixed if also given this class. - print('') - print('') - for district in sorted_districts: - print('' % - (translate[district], district)) - print('') + weekday_count = 0 for date in sorted_dates: + if weekday_count == 0: + print('') + print('') + print('') + for district in sorted_districts: + print('' % + (translate[district], district)) + print('') print('') print('' % date) print('') print('') + weekday_count += 1 + if weekday_count != 7: + continue + weekday_count = 0 print('
%s
date?%s
date?%s
%s') @@ -195,6 +195,10 @@ th { text-align: left; vertical-align: bottom; } print('
') print('
') print('

Symbols

') print('
') @@ -239,10 +243,14 @@ HTML view: https://plomlompom.com/berlin_corona.html""" weekly_avgs = [] weekly_incs = [] for district in sorted_districts: - new_infections += [db[district][date]['new_infections']] - weekly_sums += [db[district][date]['week_sum']] - weekly_avgs += [db[district][date]['week_average']] - weekly_incs += [db[district][date]['week_incidence']] + district_day_data = db[district][date] + new_infections += [district_day_data['new_infections']] + if 'week_sum' in district_day_data: + weekly_sums += [district_day_data['week_sum']] + if 'week_average' in district_day_data: + weekly_avgs += [district_day_data['week_average']] + if 'week_incidence' in district_day_data: + weekly_incs += [district_day_data['week_incidence']] print('+', ' '*11, ' '.join(['%3s' % i for i in new_infections])) print('Σ', ' '*10, ' '.join(['%4s' % wsum for wsum in weekly_sums])) print('Ø', ' '*9, ''.join(['%5.1f' % wavg for wavg in weekly_avgs]))