【问题标题】:how to extract particular elements in huge json data using python and transfer them to a csv file如何使用 python 提取大量 json 数据中的特定元素并将它们传输到 csv 文件
【发布时间】:2017-07-21 17:11:20
【问题描述】:

我需要的文本元素是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",
},

【问题讨论】:

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


    【解决方案1】:

    使用json 库:

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

    【讨论】:

    • 我拥有的数据是列表中的一个字符串,所以当我转换或打印列表时,它显示一个属性错误,我需要将它们转换为 CSV 文件提前谢谢
    猜你喜欢
    • 1970-01-01
    • 2020-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多