Excel Data import based on title cell.
조회 수: 5 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!