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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
nachiket_shinde
Contributor III
Contributor III

Load QVDs from a folder one by one

Hello Friends,

  I have a folder wherein I have stored many QVDs(number not sure) with same naming convention.

eg: 1. xyz20171001

       2. xyz20171002 and so on depending on date.

My question is , how can I load 1 qvd at a time , do some transformation and store it again with same name?

example: if I have 27 files , I will load 1st file , xyz20171001 , add one column to it and store it as xyz20171001

                                            I will load 2nd file , xyz20171002 , add one column to it and store it as xyz20171002

                                                so on till 27th file.

             How will I handle if I dont know the number of files present in that folder?

Thanks in advance.

.

                                             

                                            

2 Replies
swuehl
MVP
MVP

Use a

FOR EACH File IN FILELIST(...)

//Do something with variable File

NEXT

loop. See also

For each..next ‒ QlikView

mdmukramali
Specialist III
Specialist III

Dear Nachiket,

As Mentioned by Mr.Stefan you can use For loop to achieve your result.

here is the sample Working Script:

Set vConcatenate = ;

FileList:

LOAD

'' AS SourceFile

AUTOGENERATE 0;

sub ScanFolder(Root)

for each FileExtension in 'qvd'

for each FoundFile in filelist( Root & '\*.' & FileExtension)

  Table:

LOAD District,

     [Category Name],

     [Sub Category],

     [Item Name],

     [Sales Amt TW],

     [Sales Amt LW],

     FileBaseName() as FileName

FROM

$(FoundFile)(qvd);

LET vTable = PEEK('FileName', 0, 'Table'); 

STORE Table INTO $(vTable).qvd(qvd); 

DROP Table Table;

                         

Set vConcatenate = Concatenate;

next FoundFile

next FileExtension

for each SubDirectory in dirlist( Root & '\*' )

call ScanFolder(SubDirectory)

next SubDirectory

end sub

Call ScanFolder('C:\Users\Qlik\Documents\QVD\') ;


Thanks,

mukram