Borrar filtros
Borrar filtros

Cannot Read data from text file

4 visualizaciones (últimos 30 días)
Preeti Sar
Preeti Sar el 30 de Mayo de 2018
Comentada: Preeti Sar el 31 de Mayo de 2018
All I want to do is read the comma separated values from the text file and skip the first header row. Can somebody please tell me what is wrong with my code? I have attached the text file. Thanks!
FileID = fopen('test.txt','r');
C = textscan(FileID,'%f','HeaderLines',1,'Delimiter',',');
fclose(FileID);
  1 comentario
dpb
dpb el 30 de Mayo de 2018
Editada: dpb el 30 de Mayo de 2018
The time entry is not a valid floating point value so the format string is wrong. Look up the '%D' descriptor for times or, more simply, use readtable instead that will do a better job parsing the file format automagically.

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 30 de Mayo de 2018
FileID = fopen('data.txt','r');
C = textscan(FileID,'%s %f %f','HeaderLines',1,'Delimiter',',');
fclose(FileID);
C{1}
C{2}
C{3}

Más respuestas (0)

Categorías

Más información sobre String Parsing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by