Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

Ignore an error when loading a file that does not exist

Hello,

I would like to ignore the error when loading a given file (File1) which does not exist but abort the same script if another given file (File2) does not exist.

Here's my load script:

Table1:

LOAD

Param1,

Param2

FROM [$(vConfigPath)File1.csv] txt, codepage is 1252, no labels, delimiter is ';', msq);

Table2:

LOAD

Field1,

Fiel2

FROM [$(vConfigPath)File2.csv] txt, codepage is 1252, no labels, delimiter is ';', msq);

If File1 does not exist I would like the script to continue.

If File2 does not exist I would like the script to abort.

Many thanks in advance.

Tags (1)
1 Solution

Accepted Solutions

Re: Ignore an error when loading a file that does not exist

To ignore any kind of error and be able to react appropriate (querying the ScriptError) you could follow the advise from Sunny (have a look in the help for more details). In your case you could directly query if these files exists or not. Try something like this:

if [$(vConfigPath)File1.csv] then

     Table1:

     LOAD  Param1, Param2

     FROM [$(vConfigPath)File1.csv] txt, codepage is 1252, no labels, delimiter is ';', msq);

end if

if [$(vConfigPath)File2.csv] then

     Table1:

     LOAD  Field1, Field2

     FROM [$(vConfigPath)File2.csv] txt, codepage is 1252, no labels, delimiter is ';', msq);

else

     exit script;

end if

- Marcus

3 Replies

Re: Ignore an error when loading a file that does not exist

Use this right where you want to ignore an error.

SET ErrorMode = 0;

and right after the code where you know the error comes add this

SET ErrorMode = 1;

Re: Ignore an error when loading a file that does not exist

To ignore any kind of error and be able to react appropriate (querying the ScriptError) you could follow the advise from Sunny (have a look in the help for more details). In your case you could directly query if these files exists or not. Try something like this:

if [$(vConfigPath)File1.csv] then

     Table1:

     LOAD  Param1, Param2

     FROM [$(vConfigPath)File1.csv] txt, codepage is 1252, no labels, delimiter is ';', msq);

end if

if [$(vConfigPath)File2.csv] then

     Table1:

     LOAD  Field1, Field2

     FROM [$(vConfigPath)File2.csv] txt, codepage is 1252, no labels, delimiter is ';', msq);

else

     exit script;

end if

- Marcus

Not applicable

Re: Ignore an error when loading a file that does not exist

Hello Sunny,

That's what I thought as well , but for some unknown reason it sill aborts...

Thanks for your help.

Annick

Community Browser