How to filter out missing data from a text file with readtable()? Different data types in the same column.
4 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
dpb
on 28 May 2019
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.
0 Comments
See Also
Categories
Find more on Text Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!