Created
May 8, 2024 21:27
-
-
Save andreasroste/1ac03ad4417cec55503ed80993b2e3d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import csv | |
with open('participants-roverway.json') as json_file: | |
data = json.load(json_file) | |
participant_data = data['participants'] | |
participant_data_labels = data['labels'] | |
out_file = open('participantspathid.csv', 'w', newline='') | |
csv_writer = csv.writer(out_file) | |
csv_writer.writerow([ | |
'member_no', | |
'first_name', | |
'last_name', | |
'patrol_id', | |
'patrol_name', | |
'group_id', | |
'group_name', | |
'fee' | |
]) | |
for member in participant_data: | |
if participant_data[member]['cancelled'] == False: | |
participant = [ | |
participant_data[member]['member_no'], | |
participant_data[member]['first_name'], | |
participant_data[member]['last_name'], | |
participant_data[member]['patrol_id'], | |
participant_data[member]['patrol_name'], | |
participant_data[member]['group_id'], | |
participant_data[member]['group_name'], | |
participant_data[member]['fee_id'], | |
] | |
csv_writer.writerow(participant) | |
out_file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment