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
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 CenterFile Exchange 中查找有关 Data Import and Export 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by