Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I have multiple study folders in XYZ folder and all the folders have multiple qvds. I want to concatenate QVD named AA present in all the different folders into one qvd in a separate folder. The QVD AA in all the folders have the same structure. Also, if the QVD is not found in any folder, it should not stop the concatenation of the QVDs from other below folders. How can I achieve it in a loop.
Thanks
Hey! You can try this one.
Steps in general simple
1. Create recursive function
1.1 Get path as func param
1.2 From current path(1.1) get sub dirlist
1.3 Foreach subdir from step 1.2 call again funcion getAllFolders (step 1)
1.4 Get path of all files with extension .qvd from $vPath and save into table "File"
2. For each path from 1.4 load data into table "MyTable"
3. Drop table "File" if exists
In general thats it
Sub GetAllFolders(vPath)
For each Dir in DirList('$(vPath)/*')
Call GetAllFolders('$(Dir)');
For each vFile in FileList('$(vPath)/*.qvd')
File:
load
Distinct
'$(vFile)' as files
AutoGenerate(1);
Next;
Next
End Sub;
Call GetAllFolders('lib://PDI_data');
for each vFile in FieldValueList('files')
MyTable:
LOAD
*,
FileName() as FileName
FROM [$(vFile)]
(qvd);
next;
if TableNumber('File')>=0 then
DROP TABLE File;
end if;
Dear AlzhanNurtaza,
I am new to Qlik Sense and not very good with loops, so is it possible to give little explanation on how the script is working. This will help me understand better. Thanks a lot for your response
Thanks for the great explanation, but I could not get where I can specify a specific qvd file that I want to concatenate into one qvd. For Eg. I have a QVD named Site.qvd in the multiple subfolders and I want to find the Site QVD in each subfolder and concatenate all the Site qvds into one QVD and store it in a different location and name the output file as Site_final.qvd.
Thanks for you support.