Borrar filtros
Borrar filtros

How to import excel file from multiple subfolders?

4 visualizaciones (últimos 30 días)
Jonathan Reid
Jonathan Reid el 11 de Jun. de 2019
Respondida: Bob Thompson el 11 de Jun. de 2019
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.

Respuestas (1)

Bob Thompson
Bob Thompson el 11 de Jun. de 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

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by