我有一个json文件,格式如下:
<Response>
<body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Container">
<List>
<date>2015-01-01T00:00:00+02:00</date>
<price>20164.654</price>
</List>
</body>
<resultCode>0</resultCode>
<resultDescription>success</resultDescription>
</Response>
我需要的是excel表,标签中有两列(价格和日期):
╔══════════════╦═════════════╗
║ date ║ price ║
╠══════════════╬═════════════╣
║ 2015-01-01 ║ 20164.654 ║
╚══════════════╩═════════════╝
看起来很简单,但我无法得到正确的结果。我得到的是:
╔═══════╦══════════════════════════╦═══════════╦══════════════════╗
║ ║ body ║ resultCode║ ResultDescription║
╠═══════╬══════════════════════════╬═══════════╬══════════════════╣
║ List ║ {'price': 20164.654, ║ ║ ║
║ ║ 'date': ║ ║ ║
║ ║ '2015-01-01T00:00:00. ║ ║ ║
║ ║ 000+0200'}, ║ 0 ║ success ║
║ ║ { ... etc. ║ ║ ║
╚═══════╩══════════════════════════╩═══════════╩══════════════════╝
我使用了这个简单的代码:
pandas.read_json("url").to_excel("output.xlsx")
我尝试使用 json_normalize ,但我一直收到错误。