Delete rows with certain values while keeping text in column

I have a large table with data on traffic times and modes. A sample is given below:
Now I would like to remove all rows with a zero. This would be easy to perform on a matrix with something like this:
rows_to_remove = any(data==0, 2);
data(rows_to_remove,:) = [];
However, when I load this table as a matrix, the text data on the travel mode is converted into a numerical value that has no meaning.
How do I remove all rows with a zero while keeping the text in the 5th and 7th column?

댓글 수: 5

Made a more or less temporary solution by adding 'class numbers' for each possible content of the text column, so that i can later re-add them with something of an ismember function.
However, a less long-winded solution would still be much appreciated.
"...load this table as a matrix..."??? What exactly did you do? Why not load it as a table with readtable()? And I'm not seeing any 0's in columns 5 and 7, just long strings with BIKE or GTC in them.
Rogier Busscher
Rogier Busscher 2017년 6월 8일
편집: Rogier Busscher 2017년 6월 8일
Maybe I should have been more clear.
I want to delete any row with any zero. On a matrix this can be done with the code i put above. On a table, such a command gives an error.
However, I can't use the import data tool and load the data with 'numeric matrix' as output type, because it converts the text into NaN or just a number.
So how do I do this.
Are those two numbers separated by a comma a string? Or is that like some European countries that use a comma instead of a decimal point so they are really numbers, not strings? Can you attach your data file?
Attaching a snapshot of file, wont help. To get full help, attach the file.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2017년 6월 8일

댓글:

2017년 6월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by