Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello guys
I'm using a FOR loop in my Scrip, to load some files, as follow:
For each Ticker in 'AZUL4', 'CVCB3', 'BBDC4'
LOAD... FROM
Next
But sometimes, due to some external conditions some Ticker may not be available at the time of the loading, so the script stops, show me the error, and asks for what to do...
I would like to insert some kind of code, saying that I don't care if you can't load it now, so, on error, just go to the next Ticker. How can I do ti?
Thanks
hy did I expect this question? 🙂
One solution is by using ErrorMode:
set failingTickers='';
set ErrorMode=0;
For each Ticker in $(NomeEmpresas), $(NomeBancos)
Cotação:
LOAD ... From ...;
if ScriptError>0 then
set failingTickers='$(failingTickers)$(Ticker),';
end if
Next Ticker
set ErrorMode=1;
if len('$(failingTickers)')>0 then
Trace Failing Tickers: $(failingTickers);
end if
Believe the following should likely put you on the right track:
Regards,
Brett
is your source a database or based on files?
If files, you can check with
if (isnull(filetime(Ticker_file.txt)) then
endif
load
...
next
Yes,
My source is based on files.
Actually I'm reading around 100 files.
Each file contains 5.000 rows approximately.
Would you mind to better explain how this If function works?
Thanks
hy did I expect this question? 🙂
One solution is by using ErrorMode:
set failingTickers='';
set ErrorMode=0;
For each Ticker in $(NomeEmpresas), $(NomeBancos)
Cotação:
LOAD ... From ...;
if ScriptError>0 then
set failingTickers='$(failingTickers)$(Ticker),';
end if
Next Ticker
set ErrorMode=1;
if len('$(failingTickers)')>0 then
Trace Failing Tickers: $(failingTickers);
end if
Just a quick caveat on setting ErrorMode=0, that will in fact ignore all errors, so you need to be sure things are working properly etc., as otherwise this may mask an issue, just wanted to be sure you were fully aware of this part of using that function.
Regards,
Brett
As @Brett_Bleess says all errors will be ignored with ErrorMode=0. So I would recommend you to restore the ErrorMode to 1 after you are finished loading your files in the script.
Do your initial stuff;
ErrorMode=0;
Do Your critical stuff;
ErrorMode=1;
Do the rest of your script;
@Vegar CWolf did show that in their example, but not bad to point that out again for others that drop by...
Cheers,
Brett
Yes, you met all my expectations!
Thank you so much...