Importing and appending a complete folder of excel files

3 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Jan
Jan il 28 Gen 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

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by