Excel Data import based on title cell.

조회 수: 2 (최근 30일)
Calum
Calum 2023년 3월 21일
댓글: Calum 2023년 3월 21일
Hi folks, hope you are well.
I am wondering if anyone has a method of importing specific columns of data into MATLAB arrays based on the column title alone.
I am familiar with and have used the readvars/readtable functions extensively, however these have always required me to specify a range of column cells e.g. B:B for entire column B, C:C for entire column C etc. In my current work, I would like a method that reads column data straight from the excel sheet by locating this column by title alone, instead of me having to enter the sheet and find the specific letter column. E.g. if the column of data had a title 'Names' in cell C1, I would like the call to read and import all of the data in the C column, regardless of whether this was in C or another letter column entirely. The data I am working with has consistent title names in the '1' row, but columns are often in different orders - so any help with what I'm asking would be very efficient and help me massively.
Thanks!
C.

채택된 답변

Vilém Frynta
Vilém Frynta 2023년 3월 21일
After you read the table, you could simply search for the consistent names in your row. Then, you could specify which columns you are looking for, using those names.
For example, you could load all your data and then search the first row for a "Names", which would give you index (number) of that column. Then, you could use this index to load the whole column.
Does that make sense to you?
  댓글 수: 3
Vilém Frynta
Vilém Frynta 2023년 3월 21일
Great solution as well! If your issue has been resolved, and you think my answer has helped you, I would be happy if you could formally accept it.
Calum
Calum 2023년 3월 21일
Course!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by