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

Load Script If File Exists

i have 20 load scripts and after each load table I generate one text file. So If every load script runs properly 20 files will be created.

Now what i want is to implement a solution where from the next time onwards those load scripts will only run if corresponding text file is present in the file path. Please help how to code the same?

Like below:

if( text file1 exist in file path) THEN

LOAD Table 1

END IF

if (text file 2 exist in file path) THEN

LOAD Table 2

END IF

if(text file 3 exist in file path) THEN

LOAD Table 3

END IF

.

.

.

if(text file 20 exist in file path) THEN

LOAD Table 20

END IF

 

 

1 Solution

Accepted Solutions
felipedl
Partner - Specialist III
Partner - Specialist III

You could do something like this:

 

set dir = C:\Projetos\Qlik\1.Apps\1.Extract_Transform_Automatization;

if (FileSize('$(dir)\a.txt')>0) then
[a]:
LOAD @1
FROM
[C:\Projetos\Qlik\1.Apps\1.Extract_Transform_Automatization\a.txt]
(txt, utf8, no labels, delimiter is '\t', msq);
endif;

That will only load if the file exists and has a size greater than 0kb.

 

Just repeat the same code for the others and you'll have roughly what you need.

I'd take another approach, but it'd require the DoDir() function from QDF (https://github.com/QlikDeploymentFramework/Qlik-Deployment-Framework)

to check which file exists or not.

View solution in original post

1 Reply
felipedl
Partner - Specialist III
Partner - Specialist III

You could do something like this:

 

set dir = C:\Projetos\Qlik\1.Apps\1.Extract_Transform_Automatization;

if (FileSize('$(dir)\a.txt')>0) then
[a]:
LOAD @1
FROM
[C:\Projetos\Qlik\1.Apps\1.Extract_Transform_Automatization\a.txt]
(txt, utf8, no labels, delimiter is '\t', msq);
endif;

That will only load if the file exists and has a size greater than 0kb.

 

Just repeat the same code for the others and you'll have roughly what you need.

I'd take another approach, but it'd require the DoDir() function from QDF (https://github.com/QlikDeploymentFramework/Qlik-Deployment-Framework)

to check which file exists or not.