File size: 394 Bytes
bcffb9c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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)
|