How to filter out missing data from a text file with readtable()? Different data types in the same column.

조회 수: 4 (최근 30일)
I want to use readtable() to read this textfile I have, however the textfile has one column that has different types of data within it. The database I got the data from is supposed to give me a number for every hour of every day, but if there was no data recorded at a certain time insted of a floating point number it will have a char "M".
What is the best way for me to import this text file using readtable()? I need the information from the second and third columns, but I do not want the rows that have M as a value for the third column.
Here is an example of my data:
MKE,2008-07-08 05:52,4.83
MKE,2008-07-08 06:52,0.51
MKE,2008-07-08 07:52,M
MKE,2008-07-08 08:52,M

답변 (1개)

dpb
dpb 2019년 5월 28일
Use the 'TreatAsEmpty' named argument to read the M lines as empty and will return NaN. Then just delete the rows that return isnan() == T.

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by