Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Read about the latest Qlik Community enhancements on the Community News blog!
cancel
Showing results for 
Search instead for 
Did you mean: 
poonam_kulwal
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
stiffi88
Partner
Partner

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

flipside
Specialist II
Specialist II

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

poonam_kulwal
Partner
Partner
Author

Hello Dave,

It is very helpful. Its working. Thanks,

Sorry for late reply. I implemented this code today.