Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
alexis
Partner - Specialist
Partner - Specialist

Help with iterating a QVD file list

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

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

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

View solution in original post

3 Replies
fosuzuki
Partner - Specialist III
Partner - Specialist III

Hi,

inside your "If NoOfFiles > 0 then", you must create a loop to iterate each file.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

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

alexis
Partner - Specialist
Partner - Specialist
Author

Beautifully simple solution.

Thank you Rob.

Alexis