[英]Parsing a .json column in Power BI
I want to parse a .json column through Power BI. 我想通过Power BI解析.json列。 I have imported the data directly from the server and have a .json column in the data along with other columns. 我已经直接从服务器导入了数据,并且在数据中还有一个.json列以及其他列。 Is there a way to parse this json column? 有没有办法解析此json列?
Example: 例:
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"}
I wish to retain the other columns and also get the simplified parsed columns. 我希望保留其他列,并获得简化的解析列。
There is an easier way to do it, in the Query Editor on the column you want to read as a json: 有一种更简单的方法,在您要以json读取的列的查询编辑器中:
then the column becomes a Record that you can split in every property of the json using the button on the top right corner. 然后该列将成为一条记录,您可以使用右上角的按钮将其拆分为json的每个属性。
let
...
your_table=imported_the_data_directly_from_the_server,
json=Table.AddColumn(your_table, "NewColName", each Json.Document([JsonResult]))
in
json
And then expand record to table using Table.ExpandRecordColumn
然后使用Table.ExpandRecordColumn
将记录扩展到表
Or by clicking this button 或单击此按钮
Use Json.Document()
function to convert string to Json data. 使用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]
**this python code may useful for you ** **270 1035 ** **此python代码可能对您有用** ** 270 1035 **
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.