我有一个包含MEDIUMBLOB列的MariaDB表。这个表中有几个条目,每个对应一张照片。
当使用PowerBI连接器将数据查询到MariaDB时,我会得到“二进制”格式的数据。

但是,在用Python (IDE或PowerBI)查询相同数据时,格式不同:

更大的问题是使用此代码将图像拆分为几个位,因为PBI对其数据元素有字符限制:
Source = MariaDB.Contents("XXX.XXX.XXX.XXX:YYYY", "ZZZZZ"),
Query1= Source{[Name="Query1",Kind="Table"]}[Data],
#"Removed Top Rows" = Table.Skip(qc_westernblot_Table,1),
//Remove unnecessary columns
RemoveOtherColumns = Table.SelectColumns(#"Removed Top Rows",{"picture", "batchname"}),
//Creates Splitter function
SplitTextFunction = Splitter.SplitTextByRepeatedLengths(30000),
//Converts table of files to list
ListInput = Table.ToRows(RemoveOtherColumns),
//Function to convert binary of photo to multiple
//text values
ConvertOneFile = (InputRow as list) =>
let
BinaryIn = InputRow{0},
FileName = InputRow{1},
BinaryText = Binary.ToText(BinaryIn, BinaryEncoding.Base64),
SplitUpText = SplitTextFunction(BinaryText),
AddFileName = List.Transform(SplitUpText, each {FileName,_})
in
AddFileName,
//Loops over all photos and calls the above function
ConvertAllFiles = List.Transform(ListInput, each ConvertOneFile(_)),
//Combines lists together
CombineLists = List.Combine(ConvertAllFiles),
//Converts results to table
ToTable = #table(type table[Name=text,Pic=text],CombineLists),
//Adds index column to output table
AddIndexColumn = Table.AddIndexColumn(ToTable, "Index", 0, 1)在AddIndexColumn中
因为我是这个话题的初学者,我相信这里缺少一个直接的转换,但我自己还不明白。
我非常感谢任何帮助。谢谢!
发布于 2022-08-30 11:51:48
你打算用这些数据做什么?PBI不支持二进制数据,尽管您可以在Power查询中看到它。在将其加载到PBI数据模型之前,必须将其转换为其他内容。
我怀疑Python版本只是已经转换为文本的二进制文件。如果您单击PBI版本图片列右上角的两个箭头,难道没有得到相同的输出吗?
https://stackoverflow.com/questions/73541767
复制相似问题