none
Trying to attach a file name to multiple CSV's imported as folder RRS feed

  • Question

  • I currently have multiple CSV's imported into one power query folder. How can I attach a column with the file name.

    This is the code I have so far:

    let
        Source = Folder.Files("C:\Users\joepe\Downloads\OC Data"),
        #"Removed Other Columns" = Table.SelectColumns(Source,{"Content"}),
        #"Added Custom" = Table.AddColumn(#"Removed Other Columns", "GetExcel Data", each Excel.Workbook([Content])),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Content"}),
        #"Expanded GetExcel Data" = Table.ExpandTableColumn(#"Removed Columns", "GetExcel Data", {"Name", "Data", "Item", "Kind", "Hidden"}, {"GetExcel Data.Name", "GetExcel Data.Data", "GetExcel Data.Item", "GetExcel Data.Kind", "GetExcel Data.Hidden"}),
        #"Added Custom1" = Table.AddColumn(#"Expanded GetExcel Data", "NoHeaders", each Table.PromoteHeaders([GetExcel Data.Data])),
        #"Removed Other Columns1" = Table.SelectColumns(#"Added Custom1",{"NoHeaders"}),
        #"Expanded NoHeaders" = Table.ExpandTableColumn(#"Removed Other Columns1", "NoHeaders", {"Column1", "Column2", "Column3", "Column4", "Match Odds", "Column6", "Column7"})
    in
        #"Expanded NoHeaders"

    Any help much appreciated!! 

    Monday, October 23, 2017 6:19 PM

Answers

All replies