如何过滤出JSON文件的特定键值对并将其余部分写入CSV?在
例如,过滤掉headerName
键并将URL, Domain, Pages
写入CSV文件:
[{"URL": "http://help.abc.com/", "headerName": Null, "Domain": "www.abc.com", "Pages": "27"},
{"URL": "https://support.bcd.com/", "headerName": Null, "Domain": "www.bcd.com", "Pages": "15"}]
这将产生:
^{pr2}$
使用^{} instance 处理将这些写入文件的操作,将}作为字段名,并将
URL
、Domain
和{extrasaction
参数设置为'ignore'
:然后,您可以直接将字典列表传递给
writer.writerows()
方法:相关问题 更多 >
编程相关推荐