Forum Discussion
Import files with different extension type from the same folder
- 6 years ago
You can modify your Power Query code to use different file ingestion routines (called functions) depending on the extension type of the file. Note that .xlsx files have a totally different structure (and potentially many tabs that you need to choose from) than plain .txt files.
Something like this
let
Source = SharePoint.Files("https://xxx.sharepoint.com/teams/yyy", [ApiVersion = 15]),
#"Filtered Rows" = Table.SelectRows(Source, each ([Extension] = ".txt" or [Extension] = ".xlsx")),
#"Get File Contents" = Table.AddColumn(#"Filtered Rows", "File", each if [Extension]=".txt" then GetTXT([Content]) else GetXLSX([Content]))in
#"Get File Contents"
Davide_V , Import a excel file separately. Go go data transformation/ Edit Query mode. Right-click on the table and open the Advance editor.
Take this code.
Do the same with the text file.
Now compare the code and move the changes in excel source code text source code.
Take care of Path , column name and Type