The following loop reads data from excel into matlab with the use of actxserver. The loop wont complete due to an error which states that the data from excel is too great. I find this hard to believe as there are 75 excel sheets each with approximately 14000 rows and 21 columns so the dataset isn't extremely massive. Therefore, I'm not sure if its the loop which is causing the problem or the dataset is too big.
The script is as follows:
clear all%obtain the name of each of the folders under investigation
path='F:\University\CEH Lancaster\Project\Practice'; folder = path; dirListing = dir(folder); dirListing=dirListing(3:end);%first 2 are just pointers
for i=1:length(dirListing); Folder_Name{i}=dirListing(i,1).name; f{i} = fullfile(path, dirListing(i,1).name);%obtain the name of each folder
files{i}=dir(fullfile(f{i},'*.xls'));%find the .xls files
for j=1:length(files{1,i}); File_Name{1,i}{j,1}=files{1,i}(j,1).name;%find the name of each .xls file in each folder
endend%manually obtain the name of the required worksheets
Name_workbook={'Data1', 'Data2', 'Data3', 'Data4'};%read data in from excel
excel = actxserver('Excel.Application');excel.Visible=0;for i=1:length(File_Name); a(i)=length(File_Name{1,i}); for j=1:a(i); file{1,i}{j,1}=excel.Workbooks.Open(fullfile(path,Folder_Name{1,i},File_Name{1,i}{j,1})); sheet1{1,i}{j,1}=excel.Worksheets.get('Item', Name_workbook(1,i)); MyRange{1,i}{j,1}=sheet1{1,i}{j,1}.UsedRange; MyData{1,i}{j,1}=MyRange{1,i}{j,1}.Value; endend
Does anyone have an opinion on what I should try next?
Best Answer