A loop for multiple .xlsx files import with different names
Show older comments
Hi,
I trying to import multiple .xlsx files from a specific folder on my Mac, but any answers that I have found on MATLAB Answers don't helped me. The files' name are {1501 1502 ... 1912} with this form: YYmm, but occasionally I could have few omissions and in this case, I would see the message: 'YYmm file doesn't exist'.
In any file, I have strings and numbers, what's the command more adequate to the importation?
source_dir = '~/Users/username/Documents/MATLAB/CDSUSD/Amundi1';
source_files = dir(fullfile(source_dir, '*.xls'));
for t = 1:length(source_files)
data = xlsread(fullfile(source_dir, source_files(t).name));
end
Thanks at all.
3 Comments
Mario Malic
on 8 Mar 2020
I would check first what is the output of source_files, if you can find which files are omitted, maybe there's something wrong with the name, or maybe some files are corrupted?
Mario Diaco
on 8 Mar 2020
Walter Roberson
on 8 Mar 2020
Instead of assigning to data assign to data{t}
Accepted Answer
More Answers (0)
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!