Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
On Qlik Cloud, I have QVD files stored in subdirectories, themselves located in subdirectories of a data space. Is there a simple script loading syntax to dynamically browse this tree structure to retrieve certain QVDs? Thank you.
Best regards,
Hi @herard_bertrand ,
Yes, you can.
The code below returns every single file in a Space, no matter the subfolder:
For Each vFileName in FileList('lib://DVD Rental Snowflake (DATA-DEV):DataFiles/*')
FileList:
LOAD
'$(vFileName)' AS FileName
AutoGenerate(1)
;
Next vFileName
You can replace the * with any name pattern, for example:
For Each vFileName in FileList('lib://DVD Rental Snowflake (DATA-DEV):DataFiles/*FILM*')
FileList:
LOAD
'$(vFileName)' AS FileName
AutoGenerate(1)
;
Next vFileName
Returns
Regards,
Mark Costa
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
Hi @herard_bertrand ,
can you please clarify what you mean?
At which stage do you want to be able to browse the folders? In the data load editor? And what do you mean by "dynamically"?
Hi 🙂
I try to concatenate QVD with a specific name in data load editor.
By Browsing, in fact I mean to load every qvd with a specific name in a lot of folders and sub folders. By dynamically I mean to do this without knowing the exact name of each folder / subfolders.
Thanks
Hi @herard_bertrand ,
Yes, you can.
The code below returns every single file in a Space, no matter the subfolder:
For Each vFileName in FileList('lib://DVD Rental Snowflake (DATA-DEV):DataFiles/*')
FileList:
LOAD
'$(vFileName)' AS FileName
AutoGenerate(1)
;
Next vFileName
You can replace the * with any name pattern, for example:
For Each vFileName in FileList('lib://DVD Rental Snowflake (DATA-DEV):DataFiles/*FILM*')
FileList:
LOAD
'$(vFileName)' AS FileName
AutoGenerate(1)
;
Next vFileName
Returns
Regards,
Mark Costa
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
Thanks 👍
Is there a way to bring through file-size also?
I was exploring the API for pulling in the files, but if it's possible to query the file-list directly, this seems much more elegant.
Hi @herard_bertrand ,
Definitely!
Using my example above you can add the FileSize function that returns the size in bytes (as well other file functions such as FileTime):
For Each vFileName in FileList('lib://DVD Rental Snowflake (DATA-DEV):DataFiles/*')
FileList:
LOAD
'$(vFileName)' AS FileName,
FileSize('$(vFileName)') AS Size
AutoGenerate(1)
;
Next vFileName
For more details:
https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/FileFunctions/...
Regards,
Mark Costa
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com