Jan-25-2021, 01:44 PM
don't use
json
as name, it's a built-in module and you don't want to override itdata = { "12345": { "2021-01-20": { "a": 1, "b": 3, "c": 0 }, "2021-01-21": { "a": 1, "b": 3, "c": 0 } }, "12346": { "2021-01-20": { "a": 1, "b": 3, "c": 0 }, "2021-01-21": { "a": 1, "b": 3, "c": 0 } } } for product, dates in data.items(): for adate, values in dates.items(): print(f"{product},{adate},{values['a']},{values['b']},{values['c']}")
Output:12345,2021-01-20,1,3,0
12345,2021-01-21,1,3,0
12346,2021-01-20,1,3,0
12346,2021-01-21,1,3,0
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs