In Python how to save the following JSON string into CSV file?
{
'1.txt': [],
'2.txt': [],
'5.txt': [],
'4.txt': ['3.txt','6.txt'],
'7.txt': ['8.txt']
}
The important thing is that I want to save only numbers of those entries that have children, i.e. for the above example the result would be:
4
3
6
7
8
This is what I prepared so far, but I don't know how to check for nested elements:
x = json.loads(data)
f = csv.writer(open("test.csv", "wb+"))
# Write CSV Header
f.writerow(["number"])
for x in x:
f.writerow([x[...]])