Qlik Community

Qlik Sense Data Connectivity

Discussion board where members can learn more about Qlik Sense Data Connectivity.

Announcements
If you are a Qlik Insight Bot user, join this collaborative group: JOIN GROUP
Highlighted

Qlik Sense - Load all files from a folder

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 Solution

Accepted Solutions
Highlighted

Re: Qlik Sense - Load all files from a folder

1. Go to the "Data Loading Editor":

1.png

2. Create a new conection to the folder where your files are:

2017_05_09_16_17_51_Deleted_Items_arturo.miquel.veyrat_everis.com_Outlook.png

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

View solution in original post

9 Replies
Highlighted

Re: Qlik Sense - Load all files from a folder

1. Go to the "Data Loading Editor":

1.png

2. Create a new conection to the folder where your files are:

2017_05_09_16_17_51_Deleted_Items_arturo.miquel.veyrat_everis.com_Outlook.png

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

View solution in original post

Highlighted

Re: Qlik Sense - Load all files from a folder

For loading all files from a folder one could simply use :

  load

      Field_1,

      Field_2

  from C:\YourFolder\*.* ;

Highlighted

Re: Qlik Sense - Load all files from a folder

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.

Highlighted
Contributor

Re: Qlik Sense - Load all files from a folder

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

Highlighted

Re: Qlik Sense - Load all files from a folder

Absolutely! I've edited the answer to include your correction.

Highlighted
New Contributor III

Re: Qlik Sense - Load all files from a folder

Is there any limit of files using this way?

Highlighted

Re: Qlik Sense - Load all files from a folder

I don't think so.
Highlighted
Contributor

Re: Qlik Sense - Load all files from a folder

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!!!

Highlighted

Re: Qlik Sense - Load all files from a folder

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...