Search code examples
pythonpython-3.xpandaspandasql

How to Read Nested Json file in PandasSql


I used to have a simple row and column format in table and was reading it by pandassql .

but if you have structure like below and want to get age>10 from this , how do I get it using pandassql?

  [  {
    "response":{
      "version":"1.1",
      "token":"dsfgf",
       "body":{
         "customer":{
             "customer_id":"1234567",
             "verified":"true"
           },
         "contact":{
             "email":"[email protected]",
             "mobile_number":"0123456789"
          },
         "personal":{
             "gender": "m",
             "title":"Dr.",
             "last_name":"Muster",
             "first_name":"Max",
             "family_status":"single",
             "dob":"1985-12-23",
         }
       }
     } ]

Solution

  • This is answered here:

    Pandas read nested json

    You can use json_normalize

    There is also a full description of the dame issue here:

    https://medium.com/swlh/converting-nested-json-structures-to-pandas-dataframes-e8106c59976e