Read a text file with varying number of colums
Mostrar comentarios más antiguos
I am trying to read a text file with varying number of columns, such as this:
#5:v3.0_ST:1:2631.1301,N:140.0:081.000:12.5;
#5:v3.0_ST:1:2631.1301,N:111.4:100.000:12.5:18.7:32.3;
#5:v3.0_ST:1:2631.1299,N:111.5:101.000:12.5:18.7:32.3;
#5:v3.0_ST:1:2631.1315,N:136.4:082.000:12.3;
#5:v3.0_ST:1:2631.1334,N:132.8:083.000:12.4;
The data is delimited by " : " (colon). I understand, there is some way of doing this using textscan, but I do not know how to do it for varying columns. Can someone give me a hint?
Thanks
4 comentarios
dpb
el 11 de En. de 2015
HINT:
doc fgetl
Your file has no clues in it for how many items there are per line other than counting delimiters on a line-by-line basis, unfortunately. Hence, that's the only way...
per isakson
el 12 de En. de 2015
What's the role of "," ?
Pankaj
el 12 de En. de 2015
Pankaj
el 12 de En. de 2015
Respuesta aceptada
Más respuestas (1)
Aditya Dua
el 11 de En. de 2015
0 votos
I tried this on the file segment you posted and it worked:
inp = importdata('file.txt'); where inp(k) contains the k^th line of the text file.
I'm using MATLAB R2014b
Aditya
Categorías
Más información sobre Graphics Object Properties en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!