Importing and appending a complete folder of excel files

3 ビュー (過去 30 日間)
Wesso
Wesso 2019 年 1 月 28 日
回答済み: Jan 2019 年 1 月 28 日
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?

採用された回答

Jan
Jan 2019 年 1 月 28 日
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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by