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

1 Ansicht (letzte 30 Tage)
Zoe Zhang
Zoe Zhang am 23 Sep. 2011
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~~~~~~

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 23 Sep. 2011
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 Kommentar
Zoe Zhang
Zoe Zhang am 23 Sep. 2011
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~~~

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Import from MATLAB finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by