Forum Discussion
How to import files from different paths
You could create a separate query for each file, or simply create multiple "Source" lines. Either way, just append all of them together in the end. Not sure I can be more specific. ImkeF might have some thoughts as well.
let
Source = Csv.Document(File.Contents("C:\temp\powerbi\jobid.csv"),[Delimiter=",", Columns=2, Encoding=1252, QuoteStyle=QuoteStyle.None]),
Source1 = Csv.Document(File.Contents("C:\temp\powerbi\months.csv"),[Delimiter=",", Columns=2, Encoding=1252, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"JobID", Int64.Type}, {"Date", type date}}),
#"Appended Query" = Table.Combine({Source, Source1})
in
#"Appended Query"file list is dynamical and i dont know how many files is in the table and i dont know files names...
so i cant write separate query for each file...
- ImkeF7 years agoCommunity Champion
I don't understand your request:
If you import from a folder, all files in that folder and all files in all its subfolders will be imported. UNLESS: You filter some files in them. So you just have to grab the uppermost path to grab all files in it.
If you have any other kind of logic to identify what shall be imported, please try to explain better.
- skurek7 years agoNew Member
I have files in many shared locations:
1. server in Poland, many folders and files
2. server in US, many folders and files...
3. ...
I can import all folders and files from these shared locations. BUT this cost PQ a lot of time.
Files and folders in these locations is too many.
before these files are displayed in PQ and I will filter them in pq - it takes a long, long time...
so i need to import only concrete files from shared locations...
- ImkeF7 years agoCommunity Champion
Sorry, I didn't read your original post thoroughly enough.
If you have a (dynamic) list with multiple filenames, don't use the Folder.Files-function, but instead the Excel.Workbook-function:
1) Convert your list with filepaths to a table
2) Add a custom column to that table with the following code:
Excel.Workbook(File.Contents([ColumnNameContainingPaths])){[Item="NameOfTheTables"]}[Data]You have to adjust the bolded parts and then just expand that new column.