How to import column "x" from multiple excel workbooks and create a new excel file with imported columns?

3 views (last 30 days)
I am extremely new to MATLAB and with no prior programming experience. I have a fairly large dataset, stored in excel(*.xlsx) format(2 sheets in each workbook, each sheet size with approx 660000 x 30 cells).
I need to generate spreadsheet for individual variables which are stored in same column in multiple excel workbooks (e.g. variable lat would be in column2 in all workbooks. The script that I am using is working only for 10 spreadsheets and after 10 spreadsheet I am getting 0 values.
|%This script is used in extracting single excel column from multiple files
%and writing them in another excel file
%%Load Data
dirs=dir('D:\NEE\*.xlsx');%read all the *.xlsx in the directory
%%Manipulate filenames
dircell=struct2cell(dirs); %Change the filename to strcture
filenames=dircell(1,:);
%%Read data up-to Row 17519
num = (numel(filenames)); %
Newfile = zeros(17519,num); % Allocating memory
%%Iteration
for i = 1:num
Newfile(:,i) = xlsread(filenames{i}, 1, 'L2:L17520'); % create array
end
%%create a new excel file
xlswrite('LAT07.xls',Newfile); %|
Please tell me what I am doing wrong. Your help is greatly appreciated.
  3 Comments

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!