MATLAB Answers

Importing only a fraction of a database using dataset

1 view (last 30 days)
I have a large dataset in csv format (400MB). How can I import in MatLab only the first 500 rows?

  1 Comment

Sebastiano delre
Sebastiano delre on 14 May 2016
Actually csvread does not work for me because my data contain not only numerical variables. I have also strings and cells. Is there a way I can use the function dataset?

Sign in to comment.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 14 May 2016
nc=6; % Number of column in your csv file
nr=500
data=csvread('file.csv',0,0,[0 0 nr-1 nc-1])

  4 Comments

Show 1 older comment
Sebastiano delre
Sebastiano delre on 14 May 2016
Actually csvread does not work for me because my data contain not only numerical variables. I have also strings and cells. Is there a way I can use the function dataset?
Walter Roberson
Walter Roberson on 14 May 2016
xlsread() accepts range arguments.
You have R2013b according to your other postings; you could consider readtable() . I do not know how fast that would be; I seem to remember later releases made it faster.
Sebastiano delre
Sebastiano delre on 15 May 2016
Actually I have R2014b now. readtable() works fine and it is very very fast. Thanks!

Sign in to comment.

More Answers (0)

Sign in to answer this question.