Run a code for all excel files in a folder?
古いコメントを表示
Hello, I need to run a code (Dataprocess.m) for all excel files in a folder. When I am running dataprocess.m for one file, it's working. How can I run it sequentially for all the excel files?
1 件のコメント
Bob Thompson
2018 年 10 月 15 日
I would write a for loop to run through a directory.
files = dir(folder,'*.xlsx') % Syntax here is not going to be perfect, but I'm pretty sure dir is the correct command.
for k = 1:length(files)
data_process_code_file_name_var = files(k).name % Not positive files is actually a structure class, you will have to try it
Dataprocess % Execute code
end
回答 (2 件)
madhan ravi
2018 年 10 月 16 日
0 投票
Indra
2018 年 10 月 16 日
0 投票
3 件のコメント
Bob Thompson
2018 年 10 月 17 日
What kind of error(s) are you getting? Post the message and the line as a comment and we can get back to you on it.
Indra
2018 年 10 月 17 日
Bob Thompson
2018 年 10 月 17 日
What is 'files' defining itself as? Does the dir() command come up with anything? Did you change it at all? You are probably going to have to, and I would suggest looking up the documentation on it first to make sure it is being applied correctly (I.e. right location, right options input, etc.).
カテゴリ
ヘルプ センター および File Exchange で Data Import from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!