Trouble with code to check for Excel file existence
5 ビュー (過去 30 日間)
古いコメントを表示
Hello!
xlsread() goes through a bunch of machinations before it tells you that the file doesn't exist if you mistyped the file name. I wrote the simple script to check if the file exists:
while exist('file_name','file') ~= 2
filename_root = input('File name (no xlsx)','s');
file_name = [filename_root,'.xlsx'];
end
disp('Success');
This way I could simply loop to correct an obvious misspelling. This doesn't work. I tried this:
filename_root = input('File name (no xlsx)','s');
file_name = strcat(filename_root,'.xlsx');
if exist('file_name','file') == 0
disp('Not found');
else
disp('Success');
end
and never got to "Success". Any thoughts?
Thanks!
Doug A
0 件のコメント
採用された回答
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Data Import from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!