Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Partner
Partner

Qlikview error handling in script

Hi All,

I am using for loop to load multiple csv files in my script. I wanted to implement try catch (Error handling) so that if certain csv file fails to load I can track it without stopping my script load.

 

set ErrorMode=0;

 

for i=0 to NoOfRows('Master_FileList') - 1
let vCSVPath=peek('CSVPath',$(i),'Master_FileList');

concatenate(UserNamedCalInfo)
load
Environment,
User_ID,
AccessDate
from [$(vCSVPath)];
Next I

 

if ScriptError=8 then    (HERE WHAT CONDITION I NEED TO PUT INSTEAD OF 8 . SINCE I AM READING CSV NAME THROUGH VARIABLE)

 

exit script; (I DONT WANT TO STOP MY SCRIPT EXECUTION)

 

//no file;

 

end if

Where can I look for error, I mean which particular csv file got failed to load.

Appreciate any help on this.

Regards,

Poonam

3 Replies
Partner
Partner

Re: Qlikview error handling in script

Hi Poonam,

you can do an FOR EACH Loop. This Loop goes over an folder or Datafiles.

FOR EACH File In FileList('Data\xls\*csv')

Table1:

Laod*

FROM

$(File)

(ooxml, embedded labels);

Its make it maybe easier.

Than you can check with if(NoofRows('Table1')>0) then

if there are data available.

Hopefully it will help you.

KR

Clemens

Highlighted
flipside
Valued Contributor II

Re: Qlikview error handling in script

Hi Poonam,

Using your method, if all you want is a list of missing files, then you can store CSVPath as a new field in your table ...

load

'$(vCSVPath)' as File,

Environment,
User_ID,
AccessDate
from [$(vCSVPath)];

... then compare the loaded values with your Master_FileList table ...

Set ErrorMode = 1;

FileLoadErrors:
Load CSVPath as MissingFile resident Master_FileList where Not(Exists(File,CSVPath));


Hope this helps

flipside

Partner
Partner

Re: Qlikview error handling in script

Hello Dave,

It is very helpful. Its working. Thanks,

Sorry for late reply. I implemented this code today.