Im trying to parse a nested json file with json_normalize but I keep getting an error. I already tried to use different solutions that I found, like writing the hierarchy from the columns but so far all i got was error message This is a part of the json Im using:
{'offers': [{'offerType': 'mobile-app',
'linkDest': 'app-store',
'convertsOn': 'install-and-open',
'appInfo': {'appID': '1065767207',
'previewLink': 'https://itunes.apple.com/in/app/id1065767207?mt=8',
'appName': 'Zivame - One Stop Lingerie App',
'appCategory': 'Shopping',
'appIcon': 'https://cdn-iphone.apptap.com/img/398/1065767207/586427483.jpg'},
'targets': [{'offerID': '9b5k58v8d43aftq236q17gy65',
'approvalStatus': 'approved',
'offerStatus': 'active',
'trackingLink': 'https://api.apptap.com/link/buy/iphone/1065767207/e1?clinkID=t8CTj4i9juYAKRjUoqBiHa6lDPI9enbFx9dWp-hlWov00cmXlnm0&pubID=m_73-YT52OdNcB6Uz_InRvD8VA&siteID=kPCipA&placementID={branch_placement_id}&trackingID={branch_tracking_id}',
'countries': ['IN'],
'platforms': ['iphone'],
'payout': {'amount': 0.6, 'currency': 'USD'},
'endDate': None,
'dailyConversionCap': None,
'restrictions': {'allowIncent': False,
'deviceIDRequired': False,
'sourceAppIDRequired': False,
'minOSVersion': '9.0',
'allowedPlacements': None,
'blockedPlacements': []}}]},
{'offerType': 'mobile-app',
'linkDest': 'app-store',
'convertsOn': 'install-and-open',
'appInfo': {'appID': '1070734239',
'previewLink': 'https://itunes.apple.com/in/app/id1070734239?mt=8',
'appName': 'Housejoy',
'appCategory': 'Lifestyle',
'appIcon': 'https://cdn-iphone.apptap.com/img/345/1070734239/749793232.jpg'},
'targets': [{'offerID': '1qfdu3blg6bey343yuxjwtpgm',
'approvalStatus': 'approved',
'offerStatus': 'active',
'trackingLink': 'https://api.apptap.com/link/buy/iphone/1070734239/e1?clinkID=t8CTj4i9jucFKR3XoqNsHa6lDPIyfnbFx9dWp-hlWov00cmXlnm0&pubID=m_73-YT52OdNcB6Uz_InRvD8VA&siteID=kPCipA&placementID={branch_placement_id}&trackingID={branch_tracking_id}',
'countries': ['IN'],
'platforms': ['iphone'],
'payout': {'amount': 0.94, 'currency': 'USD'},
'endDate': None,
'dailyConversionCap': None,
'restrictions': {'allowIncent': False,
'deviceIDRequired': False,
'sourceAppIDRequired': False,
'minOSVersion': '9.0',
'allowedPlacements': None,
'blockedPlacements': []}}]}
This is the code that I`m currently using to try to parse the json:
df = pd.json_normalize(data, 'offerType','linkDest','convertsOn','targets',['offerID','approvalStatus','offerStatus',
['trackingLink','countries','platforms','payout',[
'amount','currency'
],
'endDate','dailyConversionCap','restrictions',[
'deviceIDRequired','sourceAppIDRequires','minOSVersion',
'allowedPlacements','blockedPlacements'
]]], errors='ignore')
df.head(10)
I got an error regarding some commas that were missing, after I added I got the following error message:
TypeError Traceback (most recent call last) in ----> 1 df = pd.json_normalize(data, 'offerType','linkDest','convertsOn','targets',['offerID','approvalStatus','offerStatus', 2 ['trackingLink','countries','platforms','payout',[ 3 'amount','currency' 4 ], 5 'endDate','dailyConversionCap','restrictions',[
TypeError: _json_normalize() got multiple values for argument 'errors'
I added the errors='ignore' but still didn`t work. Does anybody know what this issue could be and how to fix it?
thanks in advance