Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a list of QVDs in a folder and I want to read each in turn and load it into QlikView tables.
I am reading 3 different kinds of QVD files, TypeA, TypeB and TypeC
My files are named YYYY_MM_TypeA.QVD so for example I have:
2012_11_TypeA.QVD
2012_12_TypeA.QVD
2012_12_TypeB.QVD
etc.
Dependent on what type they are I load them to the relevant QlikView table (see code below). For some reason the code executed once only (for the first file in the list) and does not process the whole set. Any ideas what it is I am doing wrong?
Best regards
Alexis
Set Filepath = '*.QVD';
Set FileDir = $(vExceptionsDir);
Sub DoDir (Dir)
Set NoOfFiles =0;
For each File in filelist(Dir & '$(Filepath)')
Let NoOfFiles= NoOfFiles+1;
Load
'$(File)' as Name,
Filesize('$(File)') as Size,
FileTime('$(File)') as FileTime
Autogenerate 1;
Next File
End Sub
Call DoDir ('$(FileDir)')
If NoOfFiles > 0 then
// My files are named YYYY_MM_filename.QVD,
// e.g 2012_11_TypeA.QVD, 2012_12_TypeA.QVD, 2012_11_TypeB.QVD
LET vExceptionFileUnderscore = findoneof('$(File)', '_', 2);
LET vExceptionFile = mid('$(File)', $(vExceptionFileUnderscore)+1);
IF vExceptionFile = 'TypeA.QVD' THEN
TypeA:
LOAD * FROM '$(File)'
//[$(FileDir)$(Filepath)]
(qvd);
ELSEIF vExceptionFile = 'TypeB.QVD' THEN
TypeB:
LOAD * FROM '$(File)'
(qvd);
ELSEIF vExceptionFile = 'TypeC.QVD' THEN
TypeC:
LOAD * FROM '$(File)'
(qvd);
ENDIF
Else
Load
'No files found' as Name
Autogenerate 1;
End If
Can you approach this requirement with a wildcard load?
TypeA:
LOAD * FROM *TypeA.qvd (qvd);
TypeB:
LOAD * FROM *TypeB.qvd (qvd);
TypeC:
LOAD * FROM *TypeC.qvd (qvd);
-Rob
Hi,
inside your "If NoOfFiles > 0 then", you must create a loop to iterate each file.
Can you approach this requirement with a wildcard load?
TypeA:
LOAD * FROM *TypeA.qvd (qvd);
TypeB:
LOAD * FROM *TypeB.qvd (qvd);
TypeC:
LOAD * FROM *TypeC.qvd (qvd);
-Rob
Beautifully simple solution.
Thank you Rob.
Alexis