Random number in a file name, how to automate xlsread?

1 回表示 (過去 30 日間)
Zoe Zhang
Zoe Zhang 2011 年 9 月 23 日
I would like to automate reading excel files into matlab.
And the file name is like: name_21-Sep-2011-12345678.xls
So basically I get one file from broker every day, and I could handle the date part in the file name, but then somehow the broker add a random number at the end of the file name which changes every day. So I need to know how to read this file using xlsread? How to handle the xxx part which is the random number?
filename = ['name_',datestr(datenum(today),'dd-mmm-yyyy'),xxx,'.xls']
Thanks a lot~~~~~~

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 9 月 23 日
If you know the file name partially, you can do this.
File=dir('name_21-Sep-2011-*.xls');
Hopefully, there is only one matched file, then you can do:
FileName=File(1).name
If it returns multiple files, then you need to find a way to narrow it down.
  1 件のコメント
Zoe Zhang
Zoe Zhang 2011 年 9 月 23 日
I never used dir before :-0
I think that will work since the date is enough to narrow down to one file, thanks a lot~~~

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by