"Unable to find or open 'Filename.txt'" error in MATLAB 2022a for files from a shared network drive.

144 ビュー (過去 30 日間)
I get the following error message when attempting to open a file from a shared network drive. The file directory loads in just fine, but I am unable to actually access the files in my loop.
"Error using readtable"
"Unable to find or open 'FlowData.txt'. Check the path and filename or file permissions."
The code being used to open these files is shown below. It was working perfectly fine and then all of a sudden stopped allowing me to access the files from the directory.
% Setting variable name for filepath for easier access (less user input). Enter date as "yyyymmdd".
file_path = "Z:\Groups\Smith_G\Ryan Poland\MultiPAS-IV\Data\NO2 Calibration\20210930";
% list contents of directory in structure for access
struct=dir(file_path+"\*.txt");
% Loop to tabulate all data from folder into new cell
Datainput={};
for n=1:length(struct)
Datainput{n}=readtable(struct(n).name);
end
Does anyone know if this issue is somehow related to my shared network, and does anyone have any ideas on how to acess these files again? Thans in advance.

採用された回答

Jeremy Hughes
Jeremy Hughes 2022 年 1 月 21 日
Try first
>> cd Z:\Groups\Smith_G\Ryan Poland\MultiPAS-IV\Data\NO2 Calibration\20210930
If that works, then you can either add Z:\Groups\Smith_G\Ryan Poland\MultiPAS-IV\Data\NO2 Calibration\20210930 to your path, or pass the full path name:
file_path = "Z:\Groups\Smith_G\Ryan Poland\MultiPAS-IV\Data\NO2 Calibration\20210930";
% list contents of directory in structure for access
files = dir(file_path+"\*.txt");
files = fullfile(file_path,{files.name});
% Loop to tabulate all data from folder into new cell
Datainput = {};
for n = 1:length(files)
Datainput{n} = readtable(files{n});
end
  1 件のコメント
Ryan Poland
Ryan Poland 2022 年 1 月 21 日
Jeremy,
I didn't have to change the directory, but I did add in the "fullfile" function and that seemed to do the trick in constructing the 'Datainput' variable in the for-loop. Thank you for your help!

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

その他の回答 (1 件)

Jon
Jon 2022 年 1 月 21 日
Sometimes Windows loses the connection to the mapped drive. Can you still open the folder in Windows File Explorer? Sometimes it is enough to browse to the file location in Windows File Explorer and then try your MATLAB again.

カテゴリ

Help Center および File ExchangeSearch Path についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by