Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Extract specific excell files from a folder and merge all the data in a single file

1 回表示 (過去 30 日間)
Raffaele Fracchetti
Raffaele Fracchetti 2020 年 3 月 27 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hello everybody,
I have a folder with 1000 excell file. I would like to copy the data from specific file and paste in a file where I will paste all the data extracted from the orginal files. I would like to do it in an automatic way but I don't know how to pass the right name to xlsread() function. Let me show you an example:
Folder of orginal files:
20200210091035.jpg
20200210091035_ave.xls
20200210091035_cur.xls
20200210091042.jpg
20200210091042_ave.xls
20200210091042_cur.xls
and so on.
I have to extract in order the data from all the "..._cur.xls" files and put it in single file. My problem is that the name of the file not vary in a continous way. The only fixed parameter is that the file I have to extract is every 3 files.
Thank you in advance to everybody.

回答 (1 件)

Anurag Agrawal
Anurag Agrawal 2020 年 3 月 30 日
編集済み: Anurag Agrawal 2020 年 3 月 30 日
Hi Raffaele
You can use dir function to filter out the content of your folder.
In this case you can use the follwoing command:
>> myFiles = dir('*_cur,xls');
% '*' here acts as a wildcard
This will help you store all the desired file in the variable myFiles which you can use later to copy data from. You can pass the myFiles(1).name, myFiles(2).name,.. and so on in xlsread() command.
  2 件のコメント
Raffaele Fracchetti
Raffaele Fracchetti 2020 年 3 月 30 日
Hello,
Thank you. It worked well.
Appreciated

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by