Read multiple excel files
34 次查看(过去 30 天)
显示 更早的评论
I am exporting multiple excel files and converting them to arrays. However, it can be time consuming to manually write the following code. So, I was thinking of using a for loop or some other technique that I don't have write repetitive code. How can I accomplish that? I really appreciate your help.
abc_table = readtable("Data\Some_Data.xlsx", 'Sheet', "abc");
def_table = readtable("Data\Some_Data.xlsx", 'Sheet', "def");
ghi_table = readtable("Data\Some_Data.xlsx", 'Sheet', "ghi");
jkl_table = readtable("Data\Some_Data.xlsx", 'Sheet', "jkl");
abc_vec = table2array(abc_table);
def_vec = table2array(def_table);
ghi_vec = table2array(ghi_table);
jkl_vec = table2array(jkl_table);
0 个评论
采纳的回答
KSSV
2022-8-2
xlFiles = dir('*.xlsx') ;
N = length(xlFiles) ;
for i = 1:N
thisFile = xlFiles(i).name ;
T = readtable(thisFile) ;
% do what you want
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!