X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/calendar?a=blobdiff_plain;ds=inline;f=enhance_table.py;h=62e503986b5aa0e59b88d32b11c878d7f3735802;hb=601ab994238dc43115be48f1c0ac0616ee7ad5f6;hp=cfb5eff9dba7e1fde9cb7709d2f00cc9f4c3cc51;hpb=c0b58478e632295d51a5a8dc6cee298c22b0b98c;p=berlin-corona-table diff --git a/enhance_table.py b/enhance_table.py index cfb5eff..62e5039 100755 --- a/enhance_table.py +++ b/enhance_table.py @@ -32,9 +32,10 @@ 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', + '+': 'new infections counted', + 'Σ': 'sum of new infections for last 7 days', + 'Ã': 'per-day average of new infections for last 7 days', + 'i': 'incidence (x per 100k inhabitants) of new infections for last 7 days', } # Read infections table path and output type. @@ -94,6 +95,10 @@ 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. +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. # @@ -103,9 +108,8 @@ sorted_dates.sort() # the table file, since we should have a human look at what mistake was # probably made. for date in sorted_dates: - sum_district = sorted_districts[-1] day_sum = 0 - for district in sorted_districts[:-1]: + for district in [d for d in sorted_districts if not d==sum_district]: day_sum += db[district][date]['new_infections'] if day_sum != db[sum_district][date]['new_infections']: raise Exception('Questionable district infection sum in %s' % date) @@ -150,26 +154,25 @@ th { text-align: left; vertical-align: bottom; }
new |
---|
%s |