I want to access multiple excel files from multiple folders and extract specific cell values.

조회 수: 8 (최근 30일)
I have multiple folders that consist of multiple subfolders that in turn consist of multiple excel files. I want to extract 3 specific cell values from each of these excel files. I'm a beginner in MATLAB and self-taught. Any help would be much appreciated.
Thank you!

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2022년 6월 21일
You may consider using this kind of approach:
MY_Folder= '...\MATLAB'; % Specify your folders where your data files are residing
FILE_Pattern = fullfile(MY_Folder, '*.xlsx'); % Specify MS Excel file extension
FILES = dir(FILE_Pattern);
F_names = {FILES.name};
for jj = 1 : length(F_names)
BFileName = FILES(jj).name;
F_FileName = fullfile(FILES(jj).folder, BFileName);
fprintf(1, 'Now reading %s\n', F_FileName);
DATA{jj} = readtable(F_FileName, 'Sheet', ???, 'Range', ???); % Specify the sheet name and cells where your data are located
...
end
  댓글 수: 2
Preethi
Preethi 2022년 6월 21일
So the folder structure goes like this:
MainFolder/ subfolder1/subfolder2/file.xlsx
subfolder1 has many subfolder2's and these subfolder2's have hundreds of excel files in them. I just need A2, C3 and C5 data written to another csv file.
Preethi
Preethi 2022년 6월 22일
The sheet names change for every loop as they are from different excel files.

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

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by