Readtable reads my timestamp data as NaN

7 ビュー (過去 30 日間)
Manash Sahoo
Manash Sahoo 2020 年 8 月 7 日
コメント済み: Manash Sahoo 2020 年 8 月 7 日
Hello everyone!
I am in a bit of a pickle, as I am trying to use readtable() to read my csv file. However, all of the data in the timestamp columns is being read in as NaNs. There are only a few exceptions where it reads it correctly. I am confused, as the formatting looks correct.
I have used, readtable(), readmatrix(), and dlmread(). I have also tried saving it as a .xlsx file, which allows me to read the file correctly. However, I have a myriad of .csv files that follow the same format, and it would be a huge pain to convert them all to .xslx.
The csv file format (copy and pasted directly from the file) goes like this:
Heart Monitor,Heart_Mon TmStamp,Accel_X,Accel_Y,Accel_Z,Accel_TmStamp,Respiratory, Resp TmStamp
370,00:40:00:799,0.86,9.59,1.45,00:40:00:803,201,00:40:00:803
367,00:40:00:805,0.99,9.46,1.04,00:40:00:808,197,00:40:00:808
365,00:40:00:811,1.25,9.57,1.81,00:40:00:814,195,00:40:00:814
365,00:40:00:816,0.96,9.44,1.03,00:40:00:820,194,00:40:00:820
Any help would pbe greatly appreciated!

採用された回答

Walter Roberson
Walter Roberson 2020 年 8 月 7 日
filename = 'heart.csv';
S = fileread(filename);
datacell = textscan(regexprep(S, ':(\d\d\d)', '.$1'), '%f%T%f%f%f%T%f%T', 'headerlines', 1, 'delimiter', ',');
You can cell2table(datacell), providing 'VariableNames' .
  1 件のコメント
Manash Sahoo
Manash Sahoo 2020 年 8 月 7 日
Thank you!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by