Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

File Exists

Hello All,

I have tried to create a loop to load files, it works except for the part where its supposed to identify if the file exists and just carry on if it doesn't...can anyone help please.

let vSYear=2016;

let vSMonth=6;

let vSPe=$(vSYear)&

  if($(vSMonth)<10,'-0','-')

  &$(vSMonth);

let vEYear=year(now());

let vEMonth=num(month(now()),'0');

let vEPe=$(vEYear)&

  if($(vEMonth)<10,'-0','-')

  &$(vEMonth);

set a='$(vSPe)';

Do While a<'$(vEPe)'

  Let vDs=1;

  Do While vDs<=31

  let vDss=if($(vDs)<10,'-0','-')

  &$(vDs);

  SET vFileName1='';

  LET $(vFileExsist1)=isnull(QvdCreateTime('$(vFileName1)'));

  //Let vFileExsist=if(FileSize($(vFileName))>0,-1,0);

  SET vFileName2='';

  Let $(vFileExsist2)=isnull(QvdCreateTime('$(vFileName2)'));

  //Let vFileExsist=if(FileSize($(vFileName))>0,-1,0);

  if $(vFileExsist1)=0 then

  t_tmp:

  LOAD DateTime as StartDate,

      ClientIdNo,

      [Age Group],

      Amount,

      TxId,

      Product

  FROM

 

  (qvd);

  End if

  if $(vFileExsist2)=0 then

  Concatenate (t_tmp)

  LOAD DateTime as StartDate,

      ClientIdNo,

      [Age Group],

      Amount,

      TxId,

      Product

  FROM

 

  (qvd);

  End if

  let vDs=$(vDs)+1;

  loop

4 Replies
kristof_j
Creator III
Creator III

And if you don't create a variable and you write this before "t_tmp:"

IF not IsNull(FileSize('$(vFileName1)')) then ...

jonathandienst
Partner - Champion III
Partner - Champion III

This line:

>>LET $(vFileExsist1)=isnull(QvdCreateTime('$(vFileName1)'));


Should read:

LET vFileExsist1 = Not(isnull(QvdCreateTime('$(vFileName1)')));

Similarly

>> Let $(vFileExsist2)=isnull(QvdCreateTime('$(vFileName2)'));

Should read:

LET vFileExsist2 = Not(IsNull(QvdCreateTime('$(vFileName2)')));

(make sure that you use consistent spelling of the varables..)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

ok, but the problem is that there are 2 if statements, and it has issues with the fact that i am not ending them, have tried 'EndIf' and 'End if'

Thanks for the help will try and see anyways

Not applicable
Author

Awesomeness, this works...thanks