import json
import pandas as pd



# list_dict = pd.read_csv('image_data.csv').to_dict(orient='records')

# for record in list_dict:
#     for key, value in record.items():
#         if key == "benign_original_task":
#             record[key] = value.replace("Benign version:", "").strip()
            
# with open("image_data.json", "w", encoding="utf-8") as f:
#     json.dump(list_dict, f, ensure_ascii=False, indent=4)
     
# df = pd.DataFrame(list_dict)
# df.to_csv("image_data.csv", index=False)

with open('new_data.json', 'r') as f:
    new_data = json.load(f)
    
df = pd.DataFrame(new_data)
df.rename(columns={"original_task": "harmful_original_task",
                   "subtasks": "harmful: benign_subtasks"}, inplace=True)
df['benign_original_task'] = 'nan'
df['Benign: benign_subtasks'] = 'nan'

df.to_csv('new_data.csv', index=False)