A loop for multiple .xlsx files import with different names
Ältere Kommentare anzeigen
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 Kommentare
Mario Malic
am 8 Mär. 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
am 8 Mär. 2020
Walter Roberson
am 8 Mär. 2020
Instead of assigning to data assign to data{t}
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Spreadsheets finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!