efficient way of importing excel sheet

1 visualizzazione (ultimi 30 giorni)
dharmin
dharmin il 8 Dic 2022
Commentato: Rik il 9 Dic 2022
%Hello everyone,
%I am trying to read excel data which contains multiple sheets. Is there any more efficient way of writing this code?
[filename,pathname,~]=uigetfile('*.xlsx','*.xlsx'); %select the excel file
fullname = fullfile(pathname,filename);
sheets = sheetnames(fullname);
[~,~,raw] = xlsread([fullname],sheets(2)); % taking sheets(2) because it contains the main data.
%is there any way to create multiple tables and the number of tables will be equal to the number of sheets.
  1 Commento
Rik
Rik il 9 Dic 2022
I recovered the removed content from the Google cache (something which anyone can do). Editing away your question is very rude. Someone spent time reading your question, understanding your issue, figuring out the solution, and writing an answer. Now you repay that kindness by ensuring that the next person with a similar question can't benefit from this answer.

Accedi per commentare.

Risposte (1)

Jonas
Jonas il 8 Dic 2022
Modificato: Jonas il 8 Dic 2022
if you activate MultiSelect in uigetfile, you can select more than one file. The resulting variables are then cell arrays with the file/folder names. You can then use a for loop if you like
even more efficient would be using dir() to get the file names etc, then you dont need to klick ;-)

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by