Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
In Qlik View, all files from a folder can be easily loaded using FileList():
for each file in FileList('C:\Users\...\Test\*')
load
$(file) as [File Name],
X as [Field X]
from $(file)
(...;
next
However, I cannot make FileList work in Qlik Sense. Any advice?
Arturo
1. Go to the "Data Loading Editor":
2. Create a new conection to the folder where your files are:
3. Cut and paste the following code:
for each file in filelist('lib://YourConnectionName\*.qvd')
YourTableName:
load
YourField1,
YourField2
from [$(file)](qvd)
next file
Solution adapted from: Read existing files
1. Go to the "Data Loading Editor":
2. Create a new conection to the folder where your files are:
3. Cut and paste the following code:
for each file in filelist('lib://YourConnectionName\*.qvd')
YourTableName:
load
YourField1,
YourField2
from [$(file)](qvd)
next file
Solution adapted from: Read existing files
For loading all files from a folder one could simply use :
load
Field_1,
Field_2
from C:\YourFolder\*.* ;
Thanks Bill!
However, I forgot to mention that I need to populate one field with the file name, so your approach is not suitable. I've just edited the question to address this issue.
Thank you Arturo for the example script.
I forgot to put the file type I am loading. The result table showed one record with the XML header.
from [$(file)] (qvd)
BR,
Bernd
Absolutely! I've edited the answer to include your correction.
Is there any limit of files using this way?
Hi Arturo,
I was following your code and made some adjustments and it works. However I would like to read ALL QVDs stored in the server. This means, I would like to replace 'lib://Stream_0600_QStorage/20_Transform/*.qvd' by 'lib://*.qvd'
It did not work. I want to avoid going folder by folder in the server, I would like to go directly to all QVDs stored in the different folders.
FOR each vFile in FileList('lib://Stream_0600_QStorage/20_Transform/*.qvd')
//variables
LET vFileName = mid('$(vFile)', index('$(vFile)', '/', -1) + 1, 40);
//-----------------------------
QVD_Info:
FIRST 1 LOAD
1 as QVDCount,
NUM(FileSize()/1000000 ,'0') as QVD_Size_MB,
FilePath() as QVD_Path,
FileTime() as QVD_Time_Created,
'$(vFileName)' as QVD_Name
FROM [$(vFile)](qvd);
//----------------------------
NEXT vFile
Any idea?
Many thanks!!!
I think you'll have to scan through all sub-folders, I'm afraid. Maybe this post helps you: https://community.qlik.com/t5/QlikView-Scripting/Load-files-from-subfolders-in-one-load-script/m-p/1...