How to transpose multiple .csv files and combine in Excel power query?

删除回忆录丶 提交于 2019-12-11 19:13:45

问题


I want to analyse some spectral data. I have a ~6500 csv files.
Each .csv file contains data with the fromat shown in pics.

How can I transpose all csv files?? ....so then....I can combine them in powerQuery??

Thank you!


回答1:


This will read in all .csv files in a directory, transpose and combine them for you

Use Home...advanced editor... to paste into PowerQuery and edit the 2nd line with the appropriate directory path

Based on Alexis Olson recent answer 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"



回答2:


I made a video about this answered

Transpose multiple csv in excel power query



来源:https://stackoverflow.com/questions/57805673/how-to-transpose-multiple-csv-files-and-combine-in-excel-power-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!