简体   繁体   English

如何使用内置工具将 excel 中的电力查询数据导出到 csv 中?

[英]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.

相关问题 如何显示内置Excel功能的进度栏? - How can I display a progress bar for a built-in Excel function? 如何将数据从 csv 文件或 excel 文件导出到 javascript ZA8CFDE6331BD59EB2AC66F8911C46B? - How can I export data from a csv file or excel file to a javascript object? 如何将行数据从highchart导出到excel文件而不是csv? - How can i export row data from highchart to excel file and not csv? 如何从Excel导出带引号的csv? - How can I export my csv from Excel with quotes? 从 excel 到 Power BI 到 Power Query:如何让用户更轻松地更新查询 - From excel to Power BI to Power Query: how can I make it easier for a user to update a query 使用ReportViewer内置功能导出到Excel - Export to Excel using ReportViewer built-in feature 如何通过Excel 2010上的Power Query和Power Pivot结合使用RAM中无法容纳的庞大csv文件 - How can I work with a huge csv file that does not fit in the RAM with a combination of Power Query and Power Pivot on Excel 2010 如何使用切片器/过滤器将数据从Power BI导出到Excel文件? - How to export data from Power BI to Excel file with slicer / filter on it? 数据从 Excel 导出到 CSV - Data export from Excel to CSV 将数据连接查询从 Excel 导出到 CSV(>2M 行) - Export Data Connection Query from Excel to CSV (>2M rows)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM