read multiple excel files in the one line of the code

I have a set of folders which contains excel files. But the name of excel files differ from folder to folder but the content in them is same.Its like GAMMA in one folder and GA and GAM in another folder.All three files don't exist in the same folder. Can i give a command to read them in the same line if it exists in the folder which i want to read...

답변 (2개)

Image Analyst
Image Analyst 2012년 7월 24일

0 개 추천

No, not unless you put three xlsread()'s on the same line of code. Why does it need to be one line of code? What's wrong with 3 lines?

댓글 수: 3

the problem is that if i give three xlsread()'s then even if one file is not there then it will give me an error...in my question the file gamma or ga or gam represent the same file but only the names of the files are different...i have something like 100 folders where 50 of my folders have gamma as the file name,25 folders have ga as the excel file name and so on..but all the excel file's have similar data which i can read and process...that is why i am asking for a way to read them without getting an error...
may be you can use
try & catch
Well you have to write robust code. Sorry about that. You'll need to construct your filename, then call exist(filename, 'file') to check that it actually exists before you call xlsread. Sorry, but robust, bulletproof code can't be written in a single line.

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

grapevine
grapevine 2012년 7월 24일
편집: grapevine 2012년 7월 24일

0 개 추천

The only way is to use this instruction in a for loop
[num,txt,raw] = xlsread(fichierExcelTest,'Sheet1')

카테고리

제품

질문:

2012년 7월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by