Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have a bunch of xml files and some of them are 0kb files. I want QlikView to load only the once that are either more than 0kb size or atleast contains some data. Whenever I try to load all files i encounter an error as below:
XML document must have a top level element.
On line number: 0. On column number: 0. System ID: file:///..TaskResults/TaskResult_*.xml.
Files:
Load
..
..
Thanks for you help in advance.
So I found a solution :
The problem is only while reading 0kb/ Corrupt XML file.
You can you something like below:
set ErrorMode=0;
{ Then your Load statement }
if (ScriptError = 1) then
exit script;
end if
set errormode=1;
Why dont you put..
set errormode = 0;
HTH
Sushil
You can easily check the file size before load:
if filesize(filename) > 0 then
...
end if
set errormode = 0;
will work,however the problem is it will ignore all the errors. I might never know if there is any-other issue.
I have tried this solution but for some reason it never worked for me. I would be very glad if u can post me the script.
I'm still rookie so need ur help..
For each vFileName in Filelist ('FilePath\*.xls')
load * where Size > 24;
Load *,
'$(vFileName)' as FileName,
SubField( SubField( '$(vFileName)','\',-1),'.',1) as FileType,
Floor( FileSize('$(vFileName)')/1024) AS Size
From [$(vFileName)];
Next vFileName
Hi.
It seems that you load the files using wildcard.
But to check the file size for each file before load you have to write the loop explicitly.
The easiest way is to use foreach + filelist as described in help and add the condition:
for each FileName in filelist('TaskResults/TaskResult_*.xml')
if filesize('$(FileName)')>0 then
load
*
from [$(FileName)] ...;
end if
next FileName;
So I found a solution :
The problem is only while reading 0kb/ Corrupt XML file.
You can you something like below:
set ErrorMode=0;
{ Then your Load statement }
if (ScriptError = 1) then
exit script;
end if
set errormode=1;
I have a question with this. Do you set up this piece of code after every load statement in your tab?
set errormode=0; - at the top of your tab
after each load statement - add
if (ScriptError = 1) then
exit script;
end if
set errormode=1;
I'm trying to understand the process and just making sure I am setting this up correct.
Thanks