Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Reading to end of data from multiple webpages

I have a FROM statement in a LOAD:

(http://finance.yahoo.com/q/hp?s=%5EDJI&a=03&b=$(Begin_Day_Select)&c=2014&d=04&e=6&f=2014&g=d&z=66&y=...] )

This page provides historical stock data.  It has several pages of data and you can navigate through it by clicking on 'First, Last, Next, Previous'.  Each click takes you to the apppropriate page.  However, I cannot load all of the data without going to each of these pages.  The 'y' variable in the address takes you to the appropriate page.  For instance, when 'y=0' it takes you to the page with the most recent data (fyi, each page has 66 different days of market data, but the dates are not continuous as the market is not open every day).  If you click 'Next' you go to the next page and the address is the same with the exception that the 'y' variable will increase by 66 (in this case y would equal 66...if I clicked 'Next' again. it would increase to 132.).  The problem I have is I do not know how to determine when I reach the end of the data and to stop the load.  I have thought of a "DO WHILE" loop, but I am not sure how to calculate the "WHILE" portion.  Is there any kind of command Qlikview uses to know when it has reached the end of data or something to that effect?  I could try to calculate the end of the data by using the y variable as a counter, but I don't see how to know the final value of 'y'.

FYI, the "Begin_Day_Select" value is a user selected date.  Eventually, all the of the date fields will be user selected, but I need to get this LOAD figured out first.


6 Replies
marcus_sommer

Perhaps the errormode could be helpful:

set errormode = 1;

- Marcus

Not applicable
Author

Marcus,

If I try and read past the end of data, will I get an error causing the

errorcount (or errormode) to change to something other than 0? So, for

example (forgive the lack of syntax, this is just a quick flow of logic to

make sure I understand):

DO WHILE errorcount = 0

Load *

FROM some webpage;

loop

Once Qlikview encounters no data or a webpage that does not exist, it will

get an errorcount of 1 and drop out the loop, right?

And Qlikview takes care of errorcount automatically...I don't have to

initialize it? Also, will it reset to 0 when I try to reload the data?

Alex

marcus_sommer

Errormode = 0 meant go further with the next step if any error occur:

Set ErrorMode=0;

DO WHILE ScriptError=8 // 8 = file not found

     Load * FROM some webpage;

loop

Set ErrorMode=1;

- Marcus

Not applicable
Author

Shouldn't the DO WHILE ScriptError be NOT EQUAL to 8? Otherwise, wouldn't

it drop out of the loop as soon as it went through it the first time?

marcus_sommer

Yes: ScriptError<>8

- Marcus

Not applicable
Author

Thanks!