Probelm importing csv file with csvread
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (3 件)
Image Analyst
2014 年 6 月 19 日
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 件のコメント
dpb
2014 年 6 月 19 日
(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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Large Files and Big Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!