A loop for multiple .xlsx files import with different names
Afficher commentaires plus anciens
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 commentaires
Mario Malic
le 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
le 8 Mar 2020
Walter Roberson
le 8 Mar 2020
Instead of assigning to data assign to data{t}
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Spreadsheets dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!