quickest way to scan excel column for keyword

4 ビュー (過去 30 日間)
chlor thanks
chlor thanks 2020 年 4 月 13 日
回答済み: Peng Li 2020 年 4 月 13 日
say I have an excel column looks something like this:
bacon cooked
3
egg boiled
1
potato fried
30
whats the quikest way to scan the column for the keyword "bacon" and return the cell after it (3) as output?
Thank you!

採用された回答

Peng Li
Peng Li 2020 年 4 月 13 日
Could try this:
suppose that you don't have a column name
tbl = readtable('yourExcelFile', 'ReadVariableNames', 0);
% N = the column index of that column you mentioned.
ind = find(contains(string(tbl.(N)), "bacon"));
tbl.(N)(ind+1) is what you need.
Note that this is suppose that you always have a number following the string, in case the last one if something that has a bacon field, you won't be able to find anything after that so the tbl.(N)(ind+1) will throw an error.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by