[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Continue ignoring Error
From: |
Søren Hauberg |
Subject: |
Re: Continue ignoring Error |
Date: |
Mon, 07 Feb 2011 15:22:00 +0100 |
man, 07 02 2011 kl. 06:09 -0800, skrev aegreen:
> Currently I am running a loop to read in ~400 csv files. Unfortunately at
> the moment the loop will exit whenever it encounters an error (often because
> of an incorrectly saved file) is there a way for Octave to continue despite
> an error, so that I don't have to continually restart my loop?
>
> On top of that is it possible for it to record say a value of a variable and
> the error message to a text file when this occurs?
You should be able to do that using a try-catch block. Your code would,
thus, look something like this
failures = [];
for k = 1:400
try
read_data ();
catch
failures (end+1) = k;
end_try_catch
endfor
where you should replace 'read_data' with whatever code you actually
want to run.
Søren