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

3 vues (au cours des 30 derniers jours)
Sean Carroll
Sean Carroll le 15 Juil 2015
Commenté : Jeremy Hughes le 16 Juil 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 commentaire
Jeremy Hughes
Jeremy Hughes le 16 Juil 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

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Data Import and Analysis dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by