Get non numerical parts from different sheets in excel file.
Mostra commenti meno recenti
Dear all,
In an excel file I have 20 sheets with study results of students (for each student one sheet). I want to make one database with the study results of these students using parts of these sheets. From each sheet I need 3 parts: The header with information of the student, and two blocks of grades. Uptill now I can do this for one sheet at a time. But I want to do it in a for loop for all the 20 sheets.
Using the function xlsread ("NameFile.xlsx",r) goes into every sheet, within the loop, but reads only the numbers in the cells, no names, and it omit parts of the excel file. The function readcell() reads every letter. But I can not find a way to add the sheet number to it, something like readcell("NameFile.xlsx",r). Is there another way to reach this goal? Taking the percentage away represents the goal I want.
This is the code I am using now:
%r=30 %number of sheets
%for k=1:r
B = readcell("TBCN202425.xlsx");
B1=P(1:6,3); %student information from the header out of sheet r
B1=(B1)'; %transpose, into a rowvector
P2=P(10:18,2:7);% block 1 with grades
j=size(P2,1); %number of rows needed
P11=repmat(P1,j,1); %create rows for student info for database
P2=[P11 P2]; %add student information to block 1 of grades
P3=P(48:50, 9:14); %block 2 with grades
i=size(P3,1); %number of rows needed
P31=repmat(P1,i,1); %create rows for student info for database
P3=[P31 P3]; %add student information to block 1 of grades
P4=[P2; P3]; % stacking block of grades
%end
writetable(P4, "Studentdatabase.xls");
1 Commento
Stephen23
il 5 Apr 2024
"But I can not find a way to add the sheet number to it, something like readcell("NameFile.xlsx",r)"
You could read the READCELL documentation and use the SHEET option:
B = readcell("TBCN202425.xlsx", "Sheet",k);
Or perhaps READTABLE would be more suitable for your file format. It would be much better if you uploaded a sample data file.
Avoid deprecated XLSREAD.
Risposta accettata
Più risposte (0)
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!