[英]How can I export power query data from excel into a csv with built-in tools?
I am trying to export a large amount of data from an ETL operation in excel for later queries.我正在尝试从 excel 中的 ETL 操作中导出大量数据以供以后查询。
In order to do so I need the data in a csv.为此,我需要 csv 中的数据。
However, excel does not allow more than 1 million rows to exist in a table.但是,excel 不允许表中存在超过 100 万行。
How can I work around this limitation?我该如何解决这个限制?
I determined this was possible by pivoting the data into cells.我确定这可以通过将数据旋转到单元格中来实现。 Since each cell can hold 32767 characters, I can compress several rows in my table into each cell.
由于每个单元格可以容纳 32767 个字符,因此我可以将表格中的几行压缩到每个单元格中。 I will choose a delimiter that is not a comma to allow for later unpivoting of columns to rows during queries against this csv.
我将选择一个不是逗号的分隔符,以便稍后在针对此 csv 的查询期间将列取消透视到行。
The custom function is:定制的 function 为:
// function to compress data for export to csv in excel
let
Source = (delimiter as text, maxChars as number, input as table, colname as text) => let
Source = input,
#"Changed Type" = Table.TransformColumnTypes(Source,{{colname, type text}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
#"Renamed Columns" = Table.RenameColumns(#"Added Index",{{colname, "main"}}),
avg = Number.RoundUp((List.Average(List.Transform(#"Renamed Columns"[main], each Text.Length(_)))),0),
compression = Number.RoundDown(maxChars/(avg +1),0),
#"Divided Column" = Table.TransformColumns(#"Renamed Columns", {{"Index", each Number.RoundDown(_ / compression,0)}}),
#"Grouped Rows" = Table.Group(#"Divided Column", {"Index"}, {{
"comp",
each Text.Combine(List.Transform(
Table.ToList(
Table.SelectColumns(
_, {"main"})
), each Text.Combine(
{_, delimiter}
) ))
}}
),
#"Removed Columns" = Table.RemoveColumns(#"Grouped Rows",{"Index"})
in
#"Removed Columns"
in
Source
Use DAX Studio to export to csv.使用 DAX Studio 导出到 csv。 It's a free tool.
这是一个免费的工具。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.