Probelm importing csv file with csvread
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I am trying to import a csv file to my matlab code but something seems to go wrong with the way I am trying to do it. The command that I type is
M = csvread('reoprt_data1.csv',7,1);
Because I want to import a specific range of measurements to a matrix and I get the following answer:
Error using dlmread (line 139) Mismatch between file and format string. Trouble reading number from file (row 1u, field 77u) ==> nity,,0.0,0.0,3.337845264468342E-4,,50.0,0.0,3.337845264468342E-4,,0.0,-3.337845264468342E-4,,0.0,-0.0,148.73287963867188,,0.0,-148.73287963867188,,0.0,Infinity,,\n
Error in csvread (line 48) m=dlmread(filename, ',', r, c);
Error in test (line 6) M = csvread('reoprt_data2.csv',7,1);
Can you please give me some help on that?
Thank you in advance.
0 comentarios
Respuestas (3)
Image Analyst
el 19 de Jun. de 2014
You forgot to attach your csv file. It looks like there are double commas and strings in there. I don't think it can handle that. Try fixing your file. You can call readtable() if you have strings and numbers on the same line.
0 comentarios
dpb
el 19 de Jun. de 2014
(row 1u, field 77u) ==> nity,,0.0,0.0,3.33...42E-4,,50.0,0.0,...0.0,Infinity,,\n
The recognized value is 'Inf', not 'Infinity'
Your choice is to either create the file with the corrected indicator value or you can try and see if textscan can manage with the 'treatasempty' field altho I've not tested.
Other than that, will have to read as text and parse each line; the way I'd do it would be to read the entire file as a cell array of strings and do a global substitution of 'Inf' for 'infinity' then use read from the memory array w/ sscanf()
0 comentarios
Ver también
Categorías
Más información sobre Large Files and Big Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!