Matlab repeated use of xlsread and xlswrite to network drive
Show older comments
I have a script that loops through raw Excel data files and writes out resulting Excel data files with nine sheets each. I call xlsread one and xlswrite nine times for each iteration of the loop. All files are being read from and written to a network drive. I am receiving an error saying that the either being read from or written to can't be found. This does not happen to one particular file, but occurs randomly.
What could be causing an exisiting file or a file being written, to not be found? Could this be due to using a network drive?
An example of an error I get would be:
XLSREAD unable to open file xxx. File xxx not found.
Accepted Answer
More Answers (1)
Joseph Cheng
on 11 Aug 2014
Edited: Joseph Cheng
on 11 Aug 2014
Without seeing how you're doing this i would say put in a debugging section in your script to check for key items. place a break point on catch part of a try,catch for when the file fails to be read/written to. Then you can check if the script is indeed specifying the file name and location correctly.
to see if it is a network issue perhaps a routine such as
n=0;
Nofile = 0;
while Nofile = 0 & n<100
File = dir(fullfile(folder,file))
if isempty(File)
Nofile = 1;
else
n=n+1;
pause(.1)
end
end
and see if there are any breaks in the communication. Perhaps the network admin limits the how quickly+frequently you can querying the network drive.
in either case you can use the while loop above with a few modifications. Firstly check for the file and if it exists then perform your read or write. if it comes out with a no file then pause for a while and try again for say 5 iterations. in the case that there is no file then you've got a timeout condition.
1 Comment
Andrew Bazyk
on 11 Aug 2014
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!