Importing and appending a complete folder of excel files

2 visualizaciones (últimos 30 días)
Wesso
Wesso el 28 de En. de 2019
Respondida: Jan el 28 de En. de 2019
Hi,
I have a folder in which I have around 225 excel files: MA1.xlsx,MA2.xlsx,....MA225.xlsx. all of them have the same column numbers. Is their a way to import all these to Matlab in one shot and append them to a table?
In other words can if all these excel files are under the folder C:\Users\w\Documents\Matla\Data , can I import the entire folder to matlab and append the files that are in it to create a large table?
Your help is greatly appreciated, otherwise I need to create the names and a loop I believe?

Respuesta aceptada

Jan
Jan el 28 de En. de 2019
It depends on what "in one shot" means. It is trivial to create a loop to import one file after the other, see FAQ: Access a sequence of files .
Base = 'C:\Users\w\Documents\Matla\Data';
List = dir(fullfile(Base, '*.xlsx'));
Result = cell(1, numel(List));
for k = 1:numel(List)
File = fullfile(Base, List(k).name);
Result = readtable(File); % Or specify what you want to import
end

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by