import json with open('fall-2021.json', 'r') as fall_fd: fall = json.load(fall_fd) last_fall = fall[-1] with open('spring-2022.json', 'r') as spring_fd: spring = json.load(spring_fd) data = [] for point in fall: point['hospitalizations'] = -1 data.append(point) for point in spring: point['new_staff'] = point['new_staff'] + last_fall['new_staff'] point['new_students'] = point['new_students'] + last_fall['new_students'] point['total_staff'] = point['total_staff'] + last_fall['total_staff'] point['total_students'] = point['total_students'] + last_fall['total_students'] data.append(point) with open('public/data.json', 'w') as data_fd: json.dump(data, data_fd, indent=2)