I have a json file containing this
[
{
"results": [
{
"names": [
"Ben",
"Sam"
]
},
{
"names": [
"John",
"Max"
]
}
]
}
]
And I want to take each string from the names array for each result and append it to a txt file called names.txt, and have each string seperated by a comma. Like this
Ben, Sam, John, Max
I haven't used Python much so I'm a bit stuck with writing to another file but also on reading from the json file. I currently have
with open('results.json') as json_file:
data = json.load(json_file)
for item in data['results']:
names = item['names']
And from there is where I'm just about stuck. Appreciate any help or advice anyone can give, thanks!