How to import excel file from multiple subfolders?
2 views (last 30 days)
Show older comments
I'm trying to import excel files which are located within subfolders. Each folder contains a excel file with the same file name (GMM1.xlsx)
Top folder -> subfolder -> List of files
2003 data ->20030622 ->GMM1.xlsx (there are also some other .xlsx files in here)
the end goal would be the have all excel data for each subfolder combined into one table.
I'm sorry I have no code, I've tried using subdir and dir and have hade no success. If anyone can help I would apreciate it.
0 Comments
Answers (1)
Bob Thompson
on 11 Jun 2019
There are two ways of doing this. If you have a more modern version of Matlab (2016b+ I believe) you can use the dir command.
files = dir('universalpath\**\GMM1.xlsx');
Alternatively, the community has written several codes which can be used to accomplish the task. I have used findfiles.m in the past. It can be found here.
https://www.mathworks.com/matlabcentral/fileexchange/57298-recursively-search-for-files
0 Comments
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!