How to skip Excel files in a loop when special characters exist as sheet names?
Mostra commenti meno recenti
I am processing multiple excel files by getting file info, finding the last sheet, if the last sheet has 'Number' in B2, I delete the file.
MS_xlsx=dir('*.xlsx'); % list of the files
for i=1:length(MS_xlsx)
[~,file]=xlsfinfo(MS_xlsx(i).name);
last_sheet=file{end};
[~,txt]=xlsread(MS_xlsx(i).name,last_sheet,'B2'); % read the text
if strcmp(txt,'Number:')
delete(MX_xlsx(i).name)
end
end
Some of the excel files have special characters within the sheet name (symbols, foreign language characters, odd spacing). The sheets are recognized as (Nut Plate???? or Nut Plate or ????) and the code errors out at the following when searching for the nonexistent sheet (Nut Plate???? or Nut Plate or ????).
[~,txt]=xlsread(SVMS_xlsx(i).name,last_sheet,'B2'); % read the text
Since this is the case, how can I skip the file if the sheet name 'doesn't exist' (it does but is translated) because MATLAB recognizes it with either additional spaces or question marks?
Risposta accettata
Più risposte (1)
Categorie
Scopri di più su Spreadsheets in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!