Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
arturomiquelveyrat
Partner - Contributor III
Partner - Contributor III

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
arturomiquelveyrat
Partner - Contributor III
Partner - Contributor III
Author

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
arturomiquelveyrat
Partner - Contributor III
Partner - Contributor III
Author

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

Anonymous
Not applicable

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

  load

      Field_1,

      Field_2

  from C:\YourFolder\*.* ;

arturomiquelveyrat
Partner - Contributor III
Partner - Contributor III
Author

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.

berndjaegle
Creator II
Creator II

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

arturomiquelveyrat
Partner - Contributor III
Partner - Contributor III
Author

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

farolito20
Contributor III
Contributor III

Is there any limit of files using this way?

arturomiquelveyrat
Partner - Contributor III
Partner - Contributor III
Author

I don't think so.
Zaga_69
Creator
Creator

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

arturomiquelveyrat
Partner - Contributor III
Partner - Contributor III
Author

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