如何转置多个.csv文件并在Excel Power查询中合并?

时间:2019-09-05 12:37:05

标签: csv transpose powerquery

Transpose seperate .csv files

Combine in single csv file in powerquery

我想分析一些光谱数据。 我有〜6500个CSV文件
每个.csv文件都包含数据,其fromat图片中所示。

如何转置所有csv文件? ....那么....我可以在powerQuery中将它们组合在一起?

谢谢!

2 个答案:

答案 0 :(得分:0)

这将读取目录中的所有.csv文件,进行转置并将它们组合在一起

使用Home ...高级编辑器...粘贴到PowerQuery中,并使用适当的目录路径编辑第二行

基于亚历克西斯·奥尔森(Alexis Olson)最近的回答Reading the first n rows of a csv without parsing the whole file in Power Query

let
Source = Folder.Files("C:\directory\subdirectory\"),
#"Filtered Rows" = Table.SelectRows(Source, each ([Extension] = ".csv")),
#"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Content", "Name"}),
#"Invert" = Table.TransformColumns(#"Removed Other Columns", {{"Content", each Table.Transpose(Csv.Document(_))}}),
MaxColumns = List.Max(List.Transform(#"Invert"[Content], each Table.ColumnCount(_))),
#"Expanded Content" = Table.ExpandTableColumn(#"Invert", "Content", List.Transform({1..MaxColumns}, each "Column" & Number.ToText(_))),
#"Promoted Headers" = Table.PromoteHeaders(#"Expanded Content", [PromoteAllScalars=true]),
#"Filtered Rows1" = Table.SelectRows(#"Promoted Headers", each ([Date] <> "Date"))
in #"Filtered Rows1"

答案 1 :(得分:0)

我做了一个关于这个答案的视频

Transpose multiple csv in excel power query