Read a column as numbers

7 visualizaciones (últimos 30 días)
Shaoni Nandi
Shaoni Nandi el 3 de Abr. de 2020
Comentada: David Hill el 3 de Abr. de 2020
I have a column with a large number of "NA" and a few numbers. When I import this from a csv file using readtable, matlab reads it as cell array. Even table2array returns a cell array instead of double. How do I read it / convert it as a column of numbers with NaNs for the "NA"s? My code is as below:
data=readtable("Data.csv");
t=table2array(data);
class(t)
ans =
'cell'

Respuesta aceptada

David Hill
David Hill el 3 de Abr. de 2020
This works just fine for me.
data=readmatrix('Data.csv');
  1 comentario
David Hill
David Hill el 3 de Abr. de 2020
opts = detectImportOptions('Data.csv');
opts.DataLines=[2 Inf];
data=readmatrix('Data.csv',opts);

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by