Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Timestamp load of the 2 last days

Hello again,


The QMC generates the following logs. I want to load only the last 2 days. In this case today and yesterday:


Root_20131030.txt 

Root_20131029.txt


Is there a more appropriate way or an example script to do this ?


Thank you very much !

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

Onur Civelek, I´ve done

1) Create a folder into my machine D:\Qlikview11\DistributionService\1\Log

2) Copied the files to this folder

3) Adjusted the script to this folder

runs smoothly

PFA the app with the data

I´ve noticed you´re using an IR version. Would you mind to upgrade it do SR3?

Regards

View solution in original post

17 Replies
Gysbert_Wassenaar

Please don't cross post: http://community.qlik.com/thread/97549


talk is cheap, supply exceeds demand
Clever_Anjos
Employee
Employee

SET PATH='yourpathgoeshere';

LET TwoDays=date(today()-2,'YYYYMMDD');

for each file in FileList('$(PATH)\Root*.txt')

  if '$(file)' follows 'Root_$(TwoDays).txt'

  // do something

  end if

next

Not applicable
Author

Hi Clever,

thank you. But how can i implement the LOAD Statement in this adviced scriptcode.

I tried this and get an error. I attached my qvw. Please can you check this

SET PATH='D:\Qlikview11\DistributionService\1\Log';

LET TwoDays=date(today()-2,'YYYYMMDD');

for each file in FileList('$(PATH)\Root_*.txt')

  if '$(file)' follows 'Root_$(TwoDays).txt'

//do something start

QMCLogfile:

LOAD @1,

     @2,

     @3,

     @4

FROM '$(file)' (txt, utf8, no labels, delimiter is ',', msq);

//do something end

  end if

next 

Can you give me an example ?

Clever_Anjos
Employee
Employee

Sorry, I have fixed it

Copy and paste to your app

SET PATH='C:\ProgramData\QlikTech\DistributionService\1\Log';

LET TwoDays=date(today()-2,'YYYYMMDD');

for each file in FileList('$(PATH)\Root_*.txt')

  let filebasename =subfield('$(file)','\',-1);

  if '$(filebasename)' follows 'Root_$(TwoDays).txt' then

  QMCLogfile:

   LOAD

    @1,

     @2,

      @3

   FROM [$(file)](txt, utf8, no labels, delimiter is '\t', msq);

  end if

next

Not applicable
Author

Hi Clever,

first of all thank you for your help. For this, I am really very grateful. But if i execute your modified script, then i get no loaded objects/objektdiagram in my diagram. The app are empty.

The variable filebasename stored the value "Root_20111222.txt"  Should this be so or it is a bug ?

Because I do not care for this old file? In named path the number of historical files.
But interesting to me are just the two latest files.

Maybe I have not expressed myself correctly, sorry for that.  My goal is to load only the (marked) last 2 actual files. if today is the 31.10.2013, then i want to establish only the files:

D:\Qlikview11\DistributionService\1\Log\Root_20131030.txt, 

D:\Qlikview11\DistributionService\1\Log\Root_20131031.txt, 

Can you please look again?

Best Regards,

Clever_Anjos
Employee
Employee

This variable is set inside the for loop, you don´t have to care about it

Have you changed the variable PATH to your log directory D:\Qlikview11\DistributionService\1\Log\? I don´t thing so...

Not applicable
Author

The Path are defined as D:\ProgramData\QlikTech\DistributionService\1\Log

i make a video for demonstration.

Thank you again.

Best Regards,

Clever_Anjos
Employee
Employee

I couldn´t open your video, maybe corrupted

Weird, because I can see the PATH into your variables set to C:\ProgramData\QlikTech\DistributionService\1\Log

Double check please

pastedImage_1.png

Not applicable
Author

the screenshot above are previously been changed, sorry.

But you are right. i dont understand that. Maybe a bug ! look at this:

Although the script is the correct path, but the directory path is stored wrong
How can that be. This is a mystery to me.