llm-playground / foo.py
joshcarp
Initial huggingface commit
bcffb9c
import json
newdata = []
with open("data.json", "r", encoding="utf8") as file:
data = json.load(file)
for elem in data:
newdata.append(
f"Convert the following message to json format: {elem['message']}\n"+
f"Details: {elem['labels']}\n"
)
# write modified data to data3.json
with open("data3.json", "w", encoding="utf8") as file:
json.dump(newdata, file, indent=4)