Borrar filtros
Borrar filtros

Readtable reads my timestamp data as NaN

8 visualizaciones (últimos 30 días)
Manash Sahoo
Manash Sahoo el 7 de Ag. de 2020
Comentada: Manash Sahoo el 7 de Ag. de 2020
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
Any help would pbe greatly appreciated!

Respuesta aceptada

Walter Roberson
Walter Roberson el 7 de Ag. de 2020
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' .

Más respuestas (0)


Community Treasure Hunt

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

Start Hunting!

Translated by