- What version of MATLAB are you using?
- Why does the CSV file have semicolons at the end of each line?
Why doesn't csvread read properly?
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I'm using csvread() to read my stored data from oscilloscope. Original file is 5000 rows long, but when I read .csv file it only reads to half of the file and every second value is 0. In the end vector is still 5000 row long but it's only half of the original. Why it does that and should I rather use textscan()?
3 个评论
采纳的回答
Jan
2017-7-20
I cannot imagine why your CSVREAD does not work. Perhaps you are reading the wrong file? The 2 semicolons at the end of the line are not nice, but the import should work inspite of this. Nevertheless, it is easy to import the file manually:
fid = fopen(FileName, 'r');
if fid == -1, error('Cannoten read file: %s', FileName); end
fgetl(fid); % Skip first line
Data = fscanf(fid, '%g, %g, %g ;;', [3, inf]).';
fclose(fid);
0 个评论
更多回答(1 个)
Kaelasha Tyler
2018-3-17
I have had exactly the same problem as Niko. While it is possible to manually import the file as Jan says, it would be nice to know why the csvread command is not working as it should, and what to do about it. Any further suggestions, much appreciated.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Workspace Variables and MAT Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!