Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello guys,
I'm trying to run this code, but sometimes I'm getting the following error message:
// Compondo o grupo das empresas
SET NomeEmpresas= 'AALR3', 'ABEV3', 'AFLT3', 'AGRO3', 'AHEB3', 'AHEB5', 'ALPA3', 'ALPA4', 'ALSO3';
For each Ticker in $(NomeEmpresas)
LOAD
'$(Ticker)' as STCK,
Holder,
Shares,
[Date Reported],
[% Out],
Value
FROM
[https://finance.yahoo.com/quote/$(Ticker).SA/holders?p=$(Ticker).SA]
(html, utf8, UserAgent is 'Mozilla/5.0', embedded labels, table is @2);
Next Ticker
Error message:
Table not found error
Table '@2' not found
LOAD
'AFLT3' as STCK,
Holder,
Shares,
[Date Reported],
[% Out],
Value
FROM
[https://finance.yahoo.com/quote/AFLT3.SA/holders?p=AFLT3.SA]
(html, utf8, UserAgent is 'Mozilla/5.0', embedded labels, table is ***)
Which is absolutely correct, once there is no Table 2 (@2) available on ...AFLT3.SA website.
My question is:
How can I create a code to check if the table exists or not, and in negative cases, just move to the next Ticker!
Thank you
set ErrorMode=0;
// Compondo o grupo das empresas
SET NomeEmpresas= 'AALR3', 'ABEV3', 'AFLT3', 'AGRO3', 'AHEB3', 'AHEB5', 'ALPA3', 'ALPA4', 'ALSO3';
For each Ticker in $(NomeEmpresas)
LOAD
'$(Ticker)' as STCK,
Holder,
Shares,
[Date Reported],
[% Out],
Value
FROM
[https://finance.yahoo.com/quote/$(Ticker).SA/holders?p=$(Ticker).SA]
(html, utf8, UserAgent is 'Mozilla/5.0', embedded labels, table is @2);
Next Ticker
set ErrorMode=0;
// Compondo o grupo das empresas
SET NomeEmpresas= 'AALR3', 'ABEV3', 'AFLT3', 'AGRO3', 'AHEB3', 'AHEB5', 'ALPA3', 'ALPA4', 'ALSO3';
For each Ticker in $(NomeEmpresas)
LOAD
'$(Ticker)' as STCK,
Holder,
Shares,
[Date Reported],
[% Out],
Value
FROM
[https://finance.yahoo.com/quote/$(Ticker).SA/holders?p=$(Ticker).SA]
(html, utf8, UserAgent is 'Mozilla/5.0', embedded labels, table is @2);
Next Ticker
Thank you!
Your solution really worked very well.
Now, considering my whole project, can I use this "Set ErrorMode=0" just for a specific part of my code, and then, set it back to 1?
Thank you
exactly!
Set ErrorMode=0;
...
YOUR CODE
...
Set ErrorMode=1;