필터 지우기
필터 지우기

Read multiple excel files

조회 수: 19 (최근 30일)
alphabetagamma
alphabetagamma 2022년 8월 2일
댓글: alphabetagamma 2022년 8월 2일
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);

채택된 답변

KSSV
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
  댓글 수: 1
alphabetagamma
alphabetagamma 2022년 8월 2일
Thanks a lot for the speedy reply and the code.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by