如何使用python在巨大的json数据中提取特定元素并将它们传输到csv文件

时间:2017-07-21 17:11:21

标签: python json python-3.x csv extraction

文本中我需要的元素是EsId,Title,Summary,text_1和keywords

"esId": "Ep-zAgDETWCS2SszbEvd_w",
"fields": {
"advancedSetting": {},
"generalInfo": {
    "en-US": {
        "description": "Manage Languages and Translations for Predefined Content",
        "keywords": "language,translations,engagement,window,agent,manager,Language,Translations,Engagement,Window,Agent,Manager,predefined content, Predefined Content",
        "thumbnail_1": "https://s3.amazonaws.com/LPGA/cms::med::691c5763-f184-4f1b-a736-f0ec644fc478",
        "title": "A Language for Each Engagement"
    },
},
"layoutInfo": {
    "en-US": {
        "summary": "<p>Keep fine-tuning the predefined content and ensure that agents can use it effectively.</p>\r\n",
        "text_1": "<p>To provide the ability to chat with visitors in a variety of languages, you can add any of the supported languages to the Engagement window.</p>\r\n\r\n<p>Along with other custom settings that you define for a specific Engagement, select the language in the Engagement window. Agents will then see the predefined content in the selected language, in their workspace, while chatting with a visitor.</p>\r\n\r\n<p>You can then duplicate the whole engagement and select a different language to target similar customers, in different languages.</p>\r\n",
        "title": "A Language for Each Engagement"
    }
},
"keywords": "language,translations,engagement,window,agent,manager,Language,Translations,Engagement,Window,Agent,Manager,predefined content, Predefined Content",
},

1 个答案:

答案 0 :(得分:0)

使用json库:

import json
data = json.loads(big_json_string)
data['EsId']
data['Title']