2021-06-10 10:45:56 +00:00
|
|
|
import json
|
2021-07-12 15:01:33 +00:00
|
|
|
import io
|
2021-06-10 10:45:56 +00:00
|
|
|
|
|
|
|
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:
|
2021-06-10 10:45:56 +00:00
|
|
|
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']})
|
2021-06-10 10:45:56 +00:00
|
|
|
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:
|
2021-06-10 10:45:56 +00:00
|
|
|
json.dump(array, file, ensure_ascii=False)
|