【发布时间】:2015-11-26 07:45:13
【问题描述】:
这是一个在 blob 存储中未压缩的文件: https://gregsouthcentralstorage.blob.core.windows.net/publiccontainer/TestFile.txt
这是相同的文件,但经过 gzip 压缩,并且 Content-Encoding blob 属性设置为 GZIP(如 here 所述): https://gregsouthcentralstorage.blob.core.windows.net/publiccontainer/TestFileGzip.txt
第二个文件的大小只有一半,但是当我在网络浏览器中查看它们时,它们看起来都一样,因为网络浏览器可以解释响应中的标头“内容编码:gzip”
现在尝试使用 Power Query 中按预期工作的第一个文件:
let
Source = Web.Contents("https://gregsouthcentralstorage.blob.core.windows.net/publiccontainer/TestFile.txt"),
#"Imported Text" = Table.FromColumns({Lines.FromBinary(Source,null,null,1252)})
in
#"Imported Text"
但是,我似乎无法使用 Power Query 中的第二个文件。这会返回乱码,因为它从不解压缩 gzip 内容:
let
Source = Web.Contents("https://gregsouthcentralstorage.blob.core.windows.net/publiccontainer/TestFileGzip.txt", [Headers=[#"Accept-Encoding"="gzip"]]),
#"Imported Text" = Table.FromColumns({Lines.FromBinary(Source,null,null,1252)})
in
#"Imported Text"
有没有办法在 Power Query 中使用 gzip 后的 Web 内容?
更新:根据 Carl Walsh 在下面的回答,我在我的 blob 的属性上大写了 Content-Encoding: GZIP。我已经上传了一个带有 Content-Encoding: gzip (lowercase) 的新 blob,它可以工作:
let
Source = Web.Contents("https://gregsouthcentralstorage.blob.core.windows.net/publiccontainer/TestFileGzipLowercase.txt"),
#"Imported Text" = Table.FromColumns({Lines.FromBinary(Source,null,null,1252)})
in
#"Imported Text"
【问题讨论】:
-
顺便说一句,Power Query 默认处理 gzip 和 deflate 编码。我会避免更改接受编码标头。
标签: powerbi powerquery