I'm new to python, and have been focusing on learning pandas and xlxswriter to help automate some workflows. I've attached a snippet of a JSON file that i got access to, and have been unable to transform into a pandas dataframe.
If i use a pd.read_json(filename): it messes up the variationProducts & productAttributes by lumping their content together in one cell.
Question: How would i take this JSON file and make it look like the pandas dataframe output at the bottom:
[
{
"ID": "12345",
"productName": "Product A ",
"minPrice": "$89.00",
"maxPrice": "$89.00",
"variationProducts": [
{
"variantColor": "JJ0BVE7",
"variantSize": "080",
"sellingPrice": "$89.00",
"inventory": 3,
},
{
"variantColor": "JJ0BVE7",
"variantSize": "085",
"sellingPrice": "$89.00",
"inventory": 6,
}
],
"productAttributes": [
{
"ID": "countryOfOrigin",
"value": "Imported"
},
{
"ID": "csProductCode",
"value": "1100"
}
]
},
{
"ID": "23456",
"productName": "Product B",
"minPrice": "$29.99",
"maxPrice": "$69.00",
"variationProducts": [
{
"variantColor": "JJ169Q0",
"variantSize": "050",
"sellingPrice": "$69.00",
"inventory": 55,
},
{
"variantColor": "JJ123Q0",
"variantSize": "055",
"sellingPrice": "$69.00",
"inventory": 5,
}
],
"productAttributes": [
{
"ID": "countryOfOrigin",
"value": "Imported"
},
{
"ID": "csProductCode",
"value": "1101"
}
]
}
]
I made this example output in excel, the variationProducts are summed up at the variantColor level - so for Product A the inventory is a summation of both variants, despite them having diffent variantSizes:
ID productName maxPrice minPrice countryOfOrigin csProductCode variantColor inventory
12345 Product A $89 $89 Imported 1100 JJ0BVE7 9
23456 Product B $69 $30 Imported 1101 JJ169Q0 55
23456 Product B $69 $30 Imported 1101 JJ123Q0 5