Forum Discussion
How to import files from different paths
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.
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.
- skurek7 years agoNew Memberthank you!
- v-piga-msft7 years agoResident Rockstar
Hi skurek,
Have you solved your problem?
If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.
If you still need help, please feel free to ask.
Best Regards,
Cherry
- KWilkinson026 years agoHelper I
Hi ImkeF would you be able to provide any more detail on this solution, I'm struggling to follow it with my basic knowledge of Power Query...
I can create a table called Filepaths with a column header called Filepaths but I'm not sure where I create the custom column or if the ColumnNameContainingPaths would be Filepaths or something else. Any assistance gratefully received.
Cheers
K.
- ImkeF6 years agoCommunity Champion
Hi KWilkinson02 ,
please start with importing just 1 file via the "From Excel-Method". Then check the M-code that has been generated. In the following steps you will replace the path to that file with the reference to a column. So the way that path has been written needs to match one of the columns from your solution.
Please check out this blogpost, which describes the general method (although it is for multiple webpages, the general princple is the same): https://www.thebiccountant.com/2018/02/10/web-scraping-1-combining-multiple-tables-from-one-page-in-power-bi-and-power-query/