I am trying to convert nested JSON into CSV using pandas. I have viewed similar questions asked here but I can't seem apply in on my scenario. My JSON is the following
{
"51% FIFTY ONE PERCENT(PWD)" : {
"ID" : "51%1574233975114-WEBAD",
"contactName" : "",
"createdAt" : 1574233975,
"debit" : 118268.19999999995,
"defaultCompany" : "",
"emailAddress" : "",
"lastUpdatedAt" : "",
"phoneNumber" : "",
"taskNumber" : 0
},
"51% STORE (MUZ)" : {
"ID" : "51%1576650784631-WEBAD",
"contactName" : "",
"createdAt" : 1576650784,
"debit" : 63860,
"defaultCompany" : "",
"emailAddress" : "",
"lastUpdatedAt" : "",
"phoneNumber" : "",
"taskNumber" : 0
},
"ABBOTT S" : {
"STORE (ABD)" : {
"ID" : "ABB1574833257715-WEBAD",
"contactName" : "",
"createdAt" : 1574833257,
"debit" : 35065,
"defaultCompany" : "",
"emailAddress" : "",
"lastUpdatedAt" : "",
"phoneNumber" : "",
"taskNumber" : 0
}
}
}
This is a snippet of the JSON and as you can see some entries, not all, are nested. I tried using the json_normalize the following way i.e.
import json
from pandas.io.json import json_normalize
with open('.\Customers\kontrolkotlin-CUSTOMERS-export.json') as f:
d = json.load(f)
nycphil = json_normalize(data = d)
nycphil
And got a single row dataframe as output as shown below
This doesn't seem to work out as I want to something readable and understandable.

