将嵌套JSON数据导入数据框或字典的最佳方法?

待定

我想知道是否有人会建议如何将嵌套的JSON数据作为数据框或字典导入?通常可以在这里获得有问题的数据-https: //ped.uspto.gov/peds/

这是数据格式的示例:

{
   "PatentBulkData":[ 
      {
         "patentCaseMetadata":{
            "applicationNumberText":{
               "value":"16732342",
               "electronicText":"16732342"
            },
            "filingDate":"2020-01-01",
            "applicationTypeCategory":"Utility",
            "partyBag":{
               "applicantBagOrInventorBagOrOwnerBag":[
                  {
                     "primaryExaminerOrAssistantExaminerOrAuthorizedOfficer":[
                        {
                           "name":{
                              "personNameOrOrganizationNameOrEntityName":[
                                 {
                                    "personFullName":"VO, PETER DUNG BA"
                                 }
                              ]
                           }
                        }
                     ]
                  },
                  {
                     "applicant":[
                        {
                           "contactOrPublicationContact":[
                              {
                                 "name":{
                                    "personNameOrOrganizationNameOrEntityName":[
                                       {
                                          "organizationStandardName":{
                                             "content":[
                                                "CYNTEC CO., LTD."
                                             ]
                                          }
                                       }
                                    ]
                                 },
                                 "cityName":"Hsinchu",
                                 "geographicRegionName":{
                                    "value":"",
                                    "geographicRegionCategory":"STATE"
                                 },
                                 "countryCode":"TW"
                              }
                           ]
                        }
                     ]
                  }
               ]
            },
            "groupArtUnitNumber":{
               "value":"3729",
               "electronicText":"3729"
            },
            "applicationConfirmationNumber":"1040",
            "applicantFileReference":"6101.179US",
            "patentClassificationBag":{
               "cpcClassificationBagOrIPCClassificationOrECLAClassificationBag":[
                  {
                     "ipOfficeCode":"US",
                     "mainNationalClassification":{
                        "nationalClass":"029",
                        "nationalSubclass":"602100"
                     }
                  }
               ]
            },
            "businessEntityStatusCategory":"UNDISCOUNTED",
            "firstInventorToFileIndicator":"true",
            "inventionTitle":{
               "content":[
                  "INDUCTOR WITH AN ELECTRODE STRUCTURE"
               ]
            },
            "applicationStatusCategory":"Docketed New Case - Ready for Examination",
            "applicationStatusDate":"2020-04-27",
            "officialFileLocationCategory":"ELECTRONIC",
            "patentPublicationIdentification":{
               "publicationNumber":"US20200135386A1",
               "publicationDate":"2020-04-30"
            }
         },
         "assignmentDataBag":{
            "assignmentData":[
               {
                  "reelNumber":"51406",
                  "frameNumber":"55",
                  "documentReceivedDate":"2020-01-03",
                  "recordedDate":"2020-01-03",
                  "mailDate":"2020-01-06",
                  "pageTotalQuantity":3,
                  "conveyanceText":"ASSIGNMENT OF ASSIGNORS INTEREST (SEE DOCUMENT FOR DETAILS).",
                  "assignorBag":{
                     "assignor":[
                        {
                           "executionDate":"2020-01-02",
                           "contactOrPublicationContact":[
                              {
                                 "name":{
                                    "personNameOrOrganizationNameOrEntityName":[
                                       {
                                          "value":"LEE, CHI-HSUN"
                                       }
                                    ]
                                 }
                              }
                           ]
                        },
                        {
                           "executionDate":"2020-01-02",
                           "contactOrPublicationContact":[
                              {
                                 "name":{
                                    "personNameOrOrganizationNameOrEntityName":[
                                       {
                                          "value":"HSIEH, HSIEH-SHEN"
                                       }
                                    ]
                                 }
                              }
                           ]
                        },
                        {
                           "executionDate":"2020-01-02",
                           "contactOrPublicationContact":[
                              {
                                 "name":{
                                    "personNameOrOrganizationNameOrEntityName":[
                                       {
                                          "value":"CHEN, SEN-HUEI"
                                       }
                                    ]
                                 }
                              }
                           ]
                        }
                     ]
                  },
                  "assigneeBag":{
                     "assignee":[
                        {
                           "contactOrPublicationContact":[
                              {
                                 "name":{
                                    "personNameOrOrganizationNameOrEntityName":[
                                       {
                                          "value":"CYNTEC CO., LTD."
                                       }
                                    ]
                                 },
                                 "postalAddressBag":{
                                    "postalAddress":[
                                       {
                                          "postalAddressText":[
                                             {
                                                "sequenceNumber":"1",
                                                "value":"NO. 2, RESEARCH & DEVELOPMENT 2ND RD."
                                             },
                                             {
                                                "sequenceNumber":"2",
                                                "value":"SCIENCE PARK"
                                             },
                                             {
                                                "sequenceNumber":"3",
                                                "value":"HSINCHU TAIWAN"
                                             }
                                          ]
                                       }
                                    ]
                                 }
                              }
                           ]
                        }
                     ]
                  },
                  "correspondenceAddress":{
                     "partyIdentifierOrContact":[
                        {
                           "name":{
                              "personNameOrOrganizationNameOrEntityName":[
                                 {
                                    "value":"LITRON INTERNATIONAL PATENT & TRADEMARK OFFICE"
                                 }
                              ]
                           },
                           "postalAddressBag":{
                              "postalAddress":[
                                 {
                                    "postalAddressText":[
                                       {
                                          "sequenceNumber":"1",
                                          "value":"11F.-2, NO.248, SEC. 3, NANJING E. RD."
                                       },
                                       {
                                          "sequenceNumber":"2",
                                          "value":"TAIPEI CITY,  TAIWAN"
                                       }
                                    ]
                                 }
                              ]
                           }
                        }
                     ]
                  },
                  "sequenceNumber":"1"
               }
            ],
            "assignmentTotalQuantity":1
         },
         "st96Version":"V3_1",
         "ipoVersion":"US_V8_0"
      },

我输入以下数据:

import json
import pandas as pd

with open('/content/drive/My Drive/2020.json') as json_file:
  data = json.load(json_file)

尽管这确实创建了字典,但将其键入“ PatentBulkData”。因此,数据的其余部分是一个列表。换句话说,当我跑步时

print(type(data['PatentBulkData']))

类型是“列表”。

理想情况下,我想再下一层,以便根据申请号文本,审查员姓名和起诉历史记录袋创建字典(可以在此处找到带有起诉历史记录袋的示例-提取/格式化数据的最佳方法JSON格式(使用Python?)。

这样做的目的是使数据成为一种格式,以便我可以根据审查员,申请人等进行分析。

我相信数据也可以XML格式提供-XML会更容易吗?

任何建议将不胜感激。谢谢!

JJ101

您要查找的命令是json_normalize。熊猫的文档非常好-https : //pandas.pydata.org/pandas-docs/stable/reference/api/pandas.json_normalize.html

因此,例如,您需要执行以下操作:

import json
import pandas as pd
from pandas import json_normalize

with open('/content/drive/My Drive/2020.json') as json_file:
  data = json.load(json_file)

df = json_normalize(data, max_level=1)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

TOP 榜单

热门标签

归档