How to load a excel file in folder?
1 view (last 30 days)
Show older comments
I wrote code which opens a csv file and progress some calculations. Now, I want to open csv files. It is hard to use 'for' loop ,because file names are irregular.
% d=dir('C:\Users\Donghwan\Desktop\mechanical loads');
c=d(3:9); %select csv files
for i=1:length(c)
x=csvread(char(c(i).name));
end
0 Comments
Accepted Answer
KSSV
on 30 Aug 2016
You can run a loop for all the (excel/csv) files in the folder. Go through the below lines of code:
xlfiles = dir('*.csv'); % You are in the folder of csv files/ change extension accordingly
Nfiles = length(xlfiles) ; % number of files
% loop for each file
for i = 1:Nfiles
fname = xlfiles(i).name ; % file name
data = xlsread(fname) ; % read the file
%%do what you want %%%
end
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!