How to import csv files with more than 100000 columns using csvread
1 次查看(过去 30 天)
显示 更早的评论
I'm trying to import csv files that have 25 rows and >100000 columns of data points.
When the file contains more than 100000 columns or data points per row, csvread is importing the data as a vector rather than matrix. This code reproduces the error on my machine:
x = rand(25,110000);
csvwrite('test.csv',x)
test = csvread('test.csv');
I would like test to be the same size as x but I get vector of size 2750000x1.
Any ideas?
1 个评论
Jeremy Hughes
2015-7-16
Hi Sean,
CSVREAD stops trying to count the number of columns at 100,000 and assumes the file contains just one long vector.
I suggest using TEXTSCAN. This code should do what you need.
fid = fopen('test.csv','r');
fmt = repmat('%f',1,110000);
d = textscan(fid,fmt,'Delimiter',',','CollectOutput',true);
test = d{:};
fclose(fid);
Hope this helps,
Jeremy
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Export 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!