How to import csv files with more than 100000 columns using csvread

7 Ansichten (letzte 30 Tage)
Sean Carroll
Sean Carroll am 15 Jul. 2015
Kommentiert: Jeremy Hughes am 16 Jul. 2015
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 Kommentar
Jeremy Hughes
Jeremy Hughes am 16 Jul. 2015
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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by