Function to read find title of an excel column
9 views (last 30 days)
Show older comments
I'm looking for a way to identify a specific column in an excel document based on the header of the column.
I have documents with a bunch of columns of data with different titles in different orders. I want to pick out the column with a specific title and make a matrix out of the data in that column. (I can't just use the number of the column because the order varies depending on the document)
Do you know any function that can help with that?
Thanks!
0 Comments
Accepted Answer
Oleg Komarov
on 18 Jun 2011
Import the excel sheet:
[data, text] = xlsread(...);
Now, use:
idx = strcmpi(text(1,:),'HeaderIamLookingFor')
data(:,idx)
0 Comments
More Answers (1)
Ahmed Elsherif
on 22 Nov 2018
Hi,
I tried this but I got a wrong value. I typed a certain header name but I got the value under a different header!
Would you please tell me why this happens?
With the code below, I got the value under another header ('Start ch.')
Thanks in advance
handles.fileName = uigetfile ('.xlsx')
[data, text] = xlsread('LT2MELT');
r = strcmpi(text(1,:),'Zero_Chann.')
k=data(:,r);
set(handles.edit40,'string', k);
0 Comments
See Also
Categories
Find more on Data Import from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!