Compare data in excel to folder location mat files.

3 vues (au cours des 30 derniers jours)
sc1991
sc1991 le 12 Sep 2017
Modifié(e) : KL le 12 Sep 2017
Hi! so I have a list of mat files that I want to extract to separate folder location. The list is in excel sheet and the mat files are stored in the windows folder, is there a way that I can compare the name in excel sheet with the files in the folder location and for every positive match extract the file and save it to a new folder.

Réponses (1)

KL
KL le 12 Sep 2017
Modifié(e) : KL le 12 Sep 2017
[~,filenames,~]=xlsread('your_excel_file.xls');
folderInfo = dir('your_folder/*.mat');
folder_filenames = {folderInfo.name};
for iFile=1:numel(filenames)
ind = 0;
ind=find(ismember(folder_filenames,filenames{iFile}));
if(ind~=0)
S(iFile).data=load(folder_filenames{iFile});
% here you could save S(iFile).data in whatever format you want to
% export and save it in different folders.
% save your target folder names in a cell array and use them
% using indexing
ind = 0;
end
end

Community Treasure Hunt

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

Start Hunting!

Translated by