繁体   English   中英

在Power BI中解析.json列

[英]Parsing a .json column in Power BI

我想通过Power BI解析.json列。 我已经直接从服务器导入了数据,并且在数据中还有一个.json列以及其他列。 有没有办法解析此json列?

例:

       Key      IDNumber    Module      JsonResult  
       012      200         Dine        {"CategoryType":"dining","City":"mumbai"',"Location":"all"} 
       97       303         Fly         {"JourneyType":"Return","Origin":"Mumbai (BOM)","Destination":"Chennai (MAA)","DepartureDate":"20-Oct-2016","ReturnDate":"21-Oct-2016","FlyAdult":"1","FlyChildren":"0","FlyInfant":"0","PromoCode":""} 
       276      6303        Stay        {"Destination":"Clarion Chennai","CheckInDate":"14-Oct-2016","CheckOutDate":"15-Oct-2016","Rooms":"1","NoOfPax":"2","NoOfAdult":"2","NoOfChildren":"0"}

我希望保留其他列,并获得简化的解析列。

有一种更简单的方法,在您要以json读取的列的查询编辑器中:

  • 右键单击列
  • 选择转换> JSON

然后该列将成为一条记录,您可以使用右上角的按钮将其拆分为json的每个属性。

拆分列

像这样使用Json.Document函数

let
    ...
    your_table=imported_the_data_directly_from_the_server,
    json=Table.AddColumn(your_table, "NewColName", each Json.Document([JsonResult]))
in
    json

然后使用Table.ExpandRecordColumn将记录扩展到表

或单击此按钮

在此处输入图片说明

使用Json.Document()函数将字符串转换为Json数据。

let
    Source = Json.Document(Json.Document(Web.Contents("http://localhost:18091/pools/default/buckets/Aggregation/docs/AvgSumAssuredByProduct"))[json]),
    #"Converted to Table" = Record.ToTable(Source),
    #"Filtered Rows" = Table.SelectRows(#"Converted to Table", each not Text.Contains([Name], "type_")),
    #"Renamed Columns" = Table.RenameColumns(#"Filtered Rows",{{"Name", "AvgSumAssuredByProduct"}}),
    #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Value", type number}})
in
    #"Changed Type"
import json
from urllib import urlopen
import string
from UserList import *
l=[]
j=[]
d_base=urlopen('https://api.thingspeak.com/channels/193888/fields/1.json?results=1')
data = json.load(d_base)
for k in data['feeds']:
        name = k['entry_id']
        value = k['field1']
        l.append(name)
        j.append(value)

print l[0]
print j[0]

**此python代码可能对您有用** ** 270 1035 **

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM