Readtable reads my timestamp data as NaN
조회 수: 4 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
채택된 답변
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' .
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!