Azzera filtri
Azzera filtri

How to import excel file from multiple subfolders?

4 visualizzazioni (ultimi 30 giorni)
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.

Risposte (1)

Bob Thompson
Bob Thompson il 11 Giu 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

Categorie

Scopri di più su File Operations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by