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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Run a script based on date from a log file

Hi,

I am trying to write a function for my loaders.  What I am trying to do is that I take a date from a log file and once that date from the log file is the same as the current date then to run the rest of the script but if it doesn’t meet the current date it will keep checking the log until the date equals the current date.

So something like this:

Function runLoader()
If date = Today then run the rest of the script
Else keep checking the date

Does anyone know how I could go about this?

Any help is much appreciated,
Mckay

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think I understand. This problem is typically solved by triggering the reload externally from the job that creates the file. However, it could be done in script as you've asked like this:

DO until NoOfRows('logtable') > 0

          Trace Reading log file;

          logtable:

          LOAD Date,

               Message

          FROM

          logfile.txt

          (txt, codepage is 1252, embedded labels, delimiter is ',', msq)

          WHERE Date = Today(1)

          ;

          Trace Sleeping...;

          SLEEP 5000;

LOOP

-Rob

http://robwunderlich.com

View solution in original post

4 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Is the "date" field you are checking a field in the log file? So you only want rows where the date = today?

-Rob

Not applicable
Author

Hi Rob,

Thanks for the reply.

The log file contains a date once the job that generates the log has been completed.

I have created a loader to create QVD's but what I want to do is write a function so that it checks this log file and when the date in the log file is the same as the current date, the function stop and the rest of the script will run.

If you understand what I mean?

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I think I understand. This problem is typically solved by triggering the reload externally from the job that creates the file. However, it could be done in script as you've asked like this:

DO until NoOfRows('logtable') > 0

          Trace Reading log file;

          logtable:

          LOAD Date,

               Message

          FROM

          logfile.txt

          (txt, codepage is 1252, embedded labels, delimiter is ',', msq)

          WHERE Date = Today(1)

          ;

          Trace Sleeping...;

          SLEEP 5000;

LOOP

-Rob

http://robwunderlich.com

Not applicable
Author

Hi Rob,
It's working perfectly- thanks alot.