Projektmanagement-Game/data/main.py

20 lines
876 B
Python
Raw Permalink Normal View History

import json
2021-07-12 15:01:33 +00:00
import io
if __name__ == '__main__':
array = []
2021-07-12 15:01:33 +00:00
with io.open('fragen_12_07_21.json', 'r', encoding='utf-8-sig') as file:
data = json.load(file)
for i in range(0, len(data)):
2021-07-12 15:01:33 +00:00
new = { 'id': int(data[i]['ID']), 'difficulty': int(data[i]['Schwierigkeit']), 'question': data[i]['Frage'], 'answers': [] }
2021-06-14 11:14:16 +00:00
2021-07-12 15:01:33 +00:00
new['answers'].append({"text": data[i]['A'], "status": 'A' == data[i]['Key']})
new['answers'].append({"text": data[i]['B'], "status": 'B' == data[i]['Key']})
new['answers'].append({"text": data[i]['C'], "status": 'C' == data[i]['Key']})
new['answers'].append({"text": data[i]['D'], "status": 'D' == data[i]['Key']})
array.append(new)
2021-07-12 15:01:33 +00:00
with open('fragen_12_07_21_new_format.json', 'w', encoding='utf8') as file:
json.dump(array, file, ensure_ascii=False)