MATLAB Answers


How to remove a row based on text in a certain column?

Asked by Treese Garofalo on 13 Jun 2019
Latest activity Commented on by Treese Garofalo on 14 Jun 2019
I'm trying to make a parser for either a .txt or .xlsx file (data can be easily converted,) but I want to omit certain lines that contain an error message. The spreadsheet has a over 100k lines and a majority of them are errors produced by the system. The error lines contain [warning] and that is the only identifier that I need to use to omit them. I've attached a screenshot of part of the data to show the format of the line. If I can post anything else that'd help let me know. Here's what I've tried so far:
DFTable(any(strcmp(table2cell(DFTable), [warning]),2), :) = []


Sign in to comment.

1 Answer

Answer by Walter Roberson
on 14 Jun 2019
 Accepted Answer

mask = contains( string(DFTtable{:,3}), '[warning]');
DFTable(mask,:) = [];

  1 Comment

Works great, thank you

Sign in to comment.