Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
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.

1 Solution

Accepted Solutions
marcus_sommer

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

View solution in original post

3 Replies
sunny_talwar

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;

marcus_sommer

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
Author

Hello Sunny,

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

Thanks for your help.

Annick