【发布时间】:2016-10-26 17:25:14
【问题描述】:
我有一个包含 3 个对象的 JSON 文件,如下所示:
[{"ID": "44585", "TITLE": "A day in *Australia*=/", "MailThread": [{"email": " Its a great day, isn't it."}, {"email": " Yes, indeed."}, {"email": " Great Day!!!"}], "SUMMARY": "", "NAME": "Mike's Journal", "PRIORITY": 3, "FLIGHTTICKETNO": 25565826, "CODENAME": "ausTrip", "DESC": "I am really feeling great*&^% to be here!! I love this place, and find it's places amazin#@$. Thanks!!"},{"ID": "44585", "TITLE": "A day in *Australia*=/", "MailThread": [{"email": " Its a great day, isn't it."}, {"email": " Yes, indeed."}, {"email": " Great Day!!!"}], "SUMMARY": "", "NAME": "Mike's Journal", "PRIORITY": 3, "FLIGHTTICKETNO": 25565826, "CODENAME": "ausTrip", "DESC": "I am really feeling great*&^% to be here!! I love this place, and find it's places amazin#@$. Thanks!!"},{"ID": "44585", "TITLE": "A day in *Australia*=/", "MailThread": [{"email": " Its a great day, isn't it."}, {"email": " Yes, indeed."}, {"email": " Great Day!!!"}], "SUMMARY": "", "NAME": "Mike's Journal", "PRIORITY": 3, "FLIGHTTICKETNO": 25565826, "CODENAME": "ausTrip", "DESC": "I am really feeling great*&^% to be here!! I love this place, and find it's places amazin#@$. Thanks!!"}]
我需要从 TITLE 中删除 *=/、&^#@ 等特殊字符,从所有 3 个对象中删除 MailThread 和 DESC 中的多个电子邮件,并将编辑后的内容写入新的 json 文件。
【问题讨论】:
-
输出是数据框?还是json?您可以添加所需的输出吗?
-
输出是 json..刚刚编辑了查询..请再看一遍!!
-
“我需要牛排”不是问题。
-
这就是我想要做的
import pandas as pd df = pd.read_json('JsonData') jsonobj = df['TITLE'] for i in jsonobj: jsonobj[i].replace('[','') print(jsonobj)它不起作用,也许这不是要牛排而是要帮忙! -
您说您需要删除MailThread 中的多封电子邮件。你的意思是全部删除还是选中?明确说明,如果您提供准确的输出会很好。