gpt4 book ai didi

使用 Power 查询将 Json 转为 Excel

转载 作者:行者123 更新时间:2023-12-01 16:52:39 28 4
gpt4 key购买 nike

我在网站上有一些 json,我想使用 power query 选项从网络将其转换为 excel.但我遇到了一个小问题。我的 json 看起来像这样:

[
{
"id" : 1,
"visitors" : 26,
"some_number" : 1,
"value" : 3500
},
{
"id" : 2,
"visitors" : 21,
"some_number" : 5,
"value" : 2000
}
]

但是当我使用来自网络时,我得到了这个:

enter image description here

我可以深入查看记录,将其转换为表格,转置并使用第一行作为标题,但然后我只得到一行。我怎样才能将所有数据放入表中,而不仅仅是一行?

最佳答案

首先,我将使用“列表工具/转换”菜单(应自动选择它)并单击到表按钮。这将为您提供一个包含 2 行的单列表。然后我会单击小展开按钮 - 它将出现在列标题中,就在“Column1”的右侧。取消选中使用原始列名...选项,您将获得一个 4 列 2 行的表格。

这是我生成的完整脚本:

let
Source = Json.Document(File.Contents("C:\Users\Mike.Honey\Downloads\json2.json")),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column2" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "visitors", "some_number", "value"}, {"id", "visitors", "some_number", "value"})
in
#"Expanded Column2"

关于使用 Power 查询将 Json 转为 Excel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42060625/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com