- M = csvread(filename) reads a comma-separated value (CSV) formatted file into array M. The file must contain only numeric values. (Emphasis added.)
CSV Import doesn't show up properly?
8 次查看(过去 30 天)
显示 更早的评论
Hey guys,
So I'm trying to import a timeseries from a csv file (dim roughly 210 x 175,000; corresponds to timepoints x voxels, file size roughly 572 MiB). When I load the file generated by my program into excel, it looks good and exactly how it should. However, when I load it into matlab, it imports as a (175000x210)x1 (ie, a 1 dimensional array whose dimensions are totally screwed up). Note that the file has a header column with the coordinates of each voxel, so I am loading the file as:
M = csvread('file/path/file.csv', 1, 0)
which should read starting at row index 1 and column index 0 (basically, just chop off the top row). why is it loading improperly into matlab? Note that in a smaller matrix that is created by the same program (200 MiB) the file loads properly and is, in that case, 210 x 50000 roughly (note that this matrix is about 3 times smaller). Is this a matlab error, or an error in creating the files? I did not actually write the code and the program is technically in a beta version, but I do not think they would screw up such a simple error, and it does load into excel just fine, it is only loading into matlab that gives it the dimensionality error. Any thoughts/suggestions?
0 个评论
回答(2 个)
Star Strider
2015-4-4
Perhaps textscan would be preferable in your application.
Your choice.
1 个评论
Star Strider
2015-4-4
I suspect that it is reading the header as numeric variables, and could be confusing some of the header information as commas, or there could be additional commas in the header.
Consider using textscan if you cannot remove the header manually, and if you know the number of columns of data you have. (If there are ‘hundreds of thousands’ of columns, use repmat to create the format descriptor string.)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!