Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
.
Use a
FOR EACH File IN FILELIST(...)
//Do something with variable File
NEXT
loop. See also
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