xlsread - Reading set number of columns with unknown number of row...

If I use xlsread with no range it takes 45 sec to read file and returns n cols x 65k rows for my file.
If I read just the columns I need by 65k it takes 20 sec to read the data I need.
Every workbook and every sheet in workbooks have a different unknown number of rows of data. So for efficient processing I would like to read columns A:D all rows for every sheet I have to process, without having to look at each sheet interactivly.
If I look at the file, there are 65k rows, if I use the active x to find the number of rows, it returns 65k as the end row. However reading the data I need with the activex takes longer than reading with xlsread and no range.
The solution would be to use xlsread and just specify the col information. (ie read a single col by specifing range C:C. However when I do this xlsread returns over a million rows of data not the 65k that are in the file. This causes a not enough store error.
Is there a way to get the faster xlsread to work properly? Adam (2011a)

Answers (1)

Strange, for me it works fine:
xlsread('test.xlsx',1,'A:D')

5 Comments

That would point to something wrong with all my excel files, however if that was the case, why would...
rowEnd = sheetObj.Range('A1').End('xlDown').Row
return the correct number of rows...
ps also...
xlsread('test.xlsx',1)
returns the correct number of rows as well...
can you upload one of the problematic files somewhere or send to my mail?
I have the same issue. Here is an example of a file causing the issue: http://www9.zippyshare.com/v/67423126/file.html
The file has only 272 rows, but using [~, ~, temp] = xlsread('1.csv','A:A'); temp will have dimension 1048576x1.
Any idea what is causing this issue? I use Win7 + MATLAB 2012a
I have no issue when using textscan:
fid = fopen('1.csv','r');
datatemp = textscan(fid, '%s %d %d %d %s %s %s %s %s %d %d', 'delimiter',',', 'CollectOutput',true, 'headerLines', 1)
fclose(fid);

Sign in to comment.

Products

Tags

Asked:

on 5 Aug 2011

Community Treasure Hunt

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

Start Hunting!