Excel Data import based on title cell.

4 ビュー (過去 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 Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by