How to read data from a specific column of excel having mixed data types
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi
I have a question. I have written a code to read data from a specific column of a specific sheet of excel and put in numdata_1. Here is the code:
for i = 1:28
i
filename = 'All files.xlsx';
sheet = i;
xlRange = 'B:B';
xlRange_2 = 'BO:BO';
numdata_1 = xlsread (filename,sheet,xlRange);
numdata_2 = xlsread (filename,sheet,xlRange_2) % (this column contains only nmeric data,so no problem for numdata_2)
There are 28 sheets in All files.xlsx. The problem is that I have 8 sheets where xlRange = 'B:B' is numeric data while 20 sheets where xlRange = 'B:B' is mixed (numeric + string/char). So, numdata_2 can not read the char or string type data from xlRange = 'B:B' and is showing only numeric type data in 20 output sheets by this command in pp.xlsx:
xlswrite('pp.xlsx',numdata_1,sheet,'C3');
xlswrite('pp.xlsx',numdata_1,sheet,'D3');
I will appreciate if someone helps me in this regard.
Thanks.
0 commentaires
Réponses (1)
Raheel Ejaz
le 1 Fév 2021
Consider using this:
[~,~,num_str] = xlsread (filename,sheet,xlRange); % num_str contains both numeric + string data.
0 commentaires
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!