Inserting excel files from different folders for different processing

조회 수: 1 (최근 30일)
Sam
Sam 2013년 12월 2일
답변: Image Analyst 2013년 12월 2일
Hi all,
I have a question about inputting data into MATLAB for some kind of analysis. I have a large amount of excel data inside different folders. Let's suppose folders are like: wp1, wp2,... and bp1, bp2,...; and inside wp folders are excel files like t1, t2,... & similarly for bp folders we have excel files like t1, t2,...
A special kind of process according to the folder name (wp or bp) should be done on excel files. The problem is how can I import all these excel files from different folders in MATLAB considering the point that MATLAB recognizes the name of the folder (wp or bp) and doing a certain process for the excel files.
Many thanks

채택된 답변

Jürgen
Jürgen 2013년 12월 2일
Hi, your question looks similar to: http://www.mathworks.com/matlabcentral/newsreader/view_thread/274014 regards,J
  댓글 수: 2
Sam
Sam 2013년 12월 2일
Thanks Jürgen,
similar but a big problem up there:
there are unknown number of folders with unknown number of excel files inside each one. The problem is how can you change the path when you don't know the number of folders (i.e. a dynamic path is needed to be generated according to number of folders).
And the second problem is the excel files inside each folder have similar names, how is it possible to call them for certain processing avoiding overwriting them!
Regards, Sam
Jürgen
Jürgen 2013년 12월 2일
you do not need to know the number of folder or the number of files with the dir command all files/folders are put in "FileList"
FileList = dir('path');
FileList = FileList(~[FileList.isdir]); %remove directories
[junk, sortorder] = sort([FileList.datenum]);
FileList = FileList(sortorder); %list is now in ascending date order
numfiles = numel(FileList);
In = cell(numfiles,1);
% Processing the images in a loop
for ii = 1:numfiles
do something with FileList(ii).name
end

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2013년 12월 2일
If you need to know how to recurse into subfolders, see the file I attached below (in blue).

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by