I am trying to convert JSON data into a CSV in Python and found this code listed on Stack Exchange from a while back (link:How can I convert JSON to CSV?). It no longer works in Python 3, giving me different errors. Anyone know how to fix for Python 3? Thanks.
Below is my JSON data:
{ "fruit": [
{ "name": "Apple",
"binomial name": "Malus domestica",
"major_producers": [ "China", "United States", "Turkey" ],
"nutrition":
{ "carbohydrates": "13.81g",
"fat": "0.17g",
"protein": "0.26g"
}
},
{ "name": "Orange",
"binomial name": "Citrus x sinensis",
"major_producers": [ "Brazil", "United States", "India" ],
"nutrition":
{ "carbohydrates": "11.75g",
"fat": "0.12g",
"protein": "0.94g"
}
},
{ "name": "Mango",
"binomial name": "Mangifera indica",
"major_producers": [ "India", "China", "Thailand" ],
"nutrition":
{ "carbohydrates": "15g",
"fat": "0.38g",
"protein": "0.82g"
}
}
] }
The output CSV should look like