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.
#
# 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)