How to read data from a specific column of excel having mixed data types
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Raheel Ejaz
2021년 2월 1일
Consider using this:
[~,~,num_str] = xlsread (filename,sheet,xlRange); % num_str contains both numeric + string data.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!