Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

beck_bakytbek
Valued Contributor III

check the folder

Hi Folks,

i have a question,

is there any examples, where i can see how to check my folder, i mean: if i create a qvd-file then this qvd-file will be stored in the folder. i want to check whether my folder is empty or not. if my folder is empty, so the qvd-file should be stored, if my folder is not empty, then should be not.

Does anybody have any idea how to handle this issue?

Thanks a lot

Beck

10 Replies
OmarBenSalem
Esteemed Contributor

Re: check the folder

if the folder is not empty, it will contain the same qvd u'll be storing?

rittermd
Honored Contributor

Re: check the folder

I have this code at the start of my script to see if the QVD exists:

LET vListqvdexists=isnull(QvdCreateTime('lib://QVDS/DTRAK\$(vCurrentYear)\Load\StopData$(vCurrentYear).QVD'));  // if qvd exists then 0 else -1

Then further down the script I check the value of this variable and then do what I need to do

beck_bakytbek
Valued Contributor III

Re: check the folder

Hi Omar,

thanks a lot for your responce.

If my folder is not emtpy then qvd should be not stored

beck_bakytbek
Valued Contributor III

Re: check the folder

Hi Mark thanks a lot for your responce,

do you have the whole example to this part of checking of qvd?

OmarBenSalem
Esteemed Contributor

Re: check the folder

if it's the case, or u know the name of the probably existing file, or use the *.fileextension, if u're not sure of its name

do sthing as follow:

SET ErrorMode=0;

LOAD data from the probably existingFile;

then delete what u've imported

if ScriptError>0 then

store ur Qvd

end if

SET ErrorMode=1;

With that, what we're doing, is :

1) negating the fact that qlik stop the reloading process if there is an error

2) try to import sthing from the file that could be in ur folder (then delete it)

3) if it's there, u won't do anything

if it's not, so normally that should be an error (if ScriptError>0 then)

=> store ur qvd

beck_bakytbek
Valued Contributor III

Re: check the folder

Hi Omar thanks a lot for your help,

i tried to to check this procedure on the base of your example, but i didn't achieve the right solution

OmarBenSalem
Esteemed Contributor

Re: check the folder

I'm using this approach in another workcase, and it does work for me.

Well, hope u'll find the right way to do it !

Have a nice day Beck

beck_bakytbek
Valued Contributor III

Re: check the folder

Omar Thanks a lot for your help and time

rittermd
Honored Contributor

Re: check the folder

That is the bulk of the code.

The variable will contain a 0 or -1. 

In my script I check the variable for a 0 (meaning the QVD does exist) and then do whatever logic I want to do based on it already existing.  Or I could do the opposite and check for a -1(does not exist)

We create QVDs that are year specific and have the year in the name.  So when we rolled into the new year I needed to do something different on the first day since it didn't exist.  After that I go back to my normal routine.

Community Browser