import json

ip = r"Responses\gpt4-turbo\agg_comp_imp_fewshot\all_temp_variation\config-974sample_25n_0.0threshold_0.4temp\updated_dataset\1_mbpp-updated-regen.json"

with open(ip, 'r') as f:
    data = json.load(f)

gen=[]
for i in data:
    temp={}
    temp['task_id'] = i['task_id']
    temp['subtask_id'] = i['subtask_id']
    temp['text'] = i['regenNL']
    temp['code'] = i['code']
    temp['test_list'] = {"original": i['test_list']['original']}
    gen.append(temp)

with open(ip.replace('.json', '_regenNL2format.json'), 'w') as f:
    json.dump(gen, f, indent=4)