Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I'm loading web data from several links. It happens that a request returns no data (supposedly web server issues) but if requested again it does return the data. I need to implement DO while LOOP into the below code so that when the requests returns no data the loop requests again until it gets the data. I've tried with FieldValue but ended up with errors. Any help will be much appreciated.
Links:
LOAD * Inline [
];
Rates:
LET vNoOfLinks = NoOfRows('Links');
FOR i=0 to $(vNoOfLinks)-1;
LET vLink = Peek('Link',$(i),'Links');
LOAD
[@1:n] as Data
FROM $(vLink) (fix, utf8);
NEXT
Regards,
Przemek
Hi,
maybe like this?:
Links:
LOAD * Inline [
Link
];
LET vNoOfLinks = NoOfRows('Links');
FOR i=0 to $(vNoOfLinks)-1;
LET vLink = Peek('Link',$(i),'Links');
LET vNoOfRowsRates = Alt(NoOfRows('Rates'),0);
DO
Rates:
LOAD
[@1:n] as Data
FROM $(vLink) (fix, utf8);
LOOP until NoOfRows('Rates') > $(vNoOfRowsRates);
NEXT;
hope this helps
regards
Marco
Hi,
one solution could be:
Links:
LOAD * Inline [
Link
];
LET vNoOfLinks = NoOfRows('Links');
FOR i=0 to $(vNoOfLinks)-1;
LET vLink = Peek('Link',$(i),'Links');
Rates:
LOAD
[@1:n] as Data
FROM $(vLink) (fix, utf8);
NEXT;
hope this helps
regards
Marco
Hi Marco,
the file you've attached is just a reloaded code of mine? Am I missing something?
Regards,
Przemek
Hi Przemek,
I thought you needed a version of your code that does not throw errors or am I missing something?
regards
Marco
Ok. Let me put this way - I run the above code, the for...next loop requests data from 3 web links. Now, link 2 returns no data because of some web server error so I end up with data from link 1 and link 3. I know that at link 2 there is some data stored and if I run the code above I will most probably get the data from link 2. So, to avoid reloading whole script I want to put in do while loop to loop until every single link returns data.
In my script there's over 50 links so the do while loop must be nested into for ... next loop not the other way round.
Regards,
Przemek
Hi,
maybe like this?:
Links:
LOAD * Inline [
Link
];
LET vNoOfLinks = NoOfRows('Links');
FOR i=0 to $(vNoOfLinks)-1;
LET vLink = Peek('Link',$(i),'Links');
LET vNoOfRowsRates = Alt(NoOfRows('Rates'),0);
DO
Rates:
LOAD
[@1:n] as Data
FROM $(vLink) (fix, utf8);
LOOP until NoOfRows('Rates') > $(vNoOfRowsRates);
NEXT;
hope this helps
regards
Marco
Beautiful! Thank you.
You're welcome
Regards
Marco
Hi Marco,
I'm struggling with another loop - a tuned version of the last one.
Table 'Rates' consists of sets of data from Links. Each Link set (except the last one) should have exactly 10 records including '*increase*' string. However, due to web server issue, a load from a Link happens to return less than 10 records with the string. In such cases I need to load the data again from this very Link. The last Link set may return less than 10 records and that's ok.
Any idea how to play this scenario?
Regards,
Przemek
Why You do this inside Qlik View ?
Regards
AC