フィルターのクリア

How to import excel file from multiple subfolders?

4 ビュー (過去 30 日間)
Jonathan Reid
Jonathan Reid 2019 年 6 月 11 日
回答済み: Bob Thompson 2019 年 6 月 11 日
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.

回答 (1 件)

Bob Thompson
Bob Thompson 2019 年 6 月 11 日
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

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by