Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Talk to Experts, a LIVE Q&A Webinar. Bring your Qlik Sense Business questions on Aug. 4th. Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor II
Contributor II

Get a list of files

Hello! So I want  to get all the files from a directory in Qlik Sense Desktop.

Found a nice post on the forum

Set vConcatenate = ;

FileList:

LOAD

'' AS SourceFile

AUTOGENERATE 0;

sub ScanFolder(Root)

          for each FileExtension in 'qvw'

                    for each FoundFile in filelist(Root & '\*.' & FileExtension)

                              FileList:

                              LOAD '$(FoundFile)' as SourceFile

       AUTOGENERATE 1;

                            

                              Set vConcatenate = Concatenate;

                    next FoundFile

          next FileExtension

          for each SubDirectory in dirlist( Root & '\*' )

                    call ScanFolder(SubDirectory)

          next SubDirectory

end sub

Call ScanFolder('C:\Users\Public\Pictures\Sample Pictures\') ;


But It's not working. The FoundFile variable is always null. I've tried with different methods and I get Null every time.

There is another example on this page Attribute ‒ Qlik Sense

But those are not working either.

What is wrong?

Tags (2)
1 Solution

Accepted Solutions
Highlighted
Master
Master

Re: Get a list of files

I just ran this code against one of my Data Connections and added a .csv extenstion and it ran and returned all of the files correctly.

I would suggest that you try this code.  Create a data connection to your folder and then change the lib statement to point to the name of the new data connection.

That should work

View solution in original post

12 Replies
Highlighted
Master
Master

Re: Get a list of files

If you are in Qlik Sense I think the issue is that you are looking for qvw extensions which are QlikView.  You want to look for qvf extensions for Qlik Sense.

Highlighted
Contributor II
Contributor II

Re: Get a list of files

The Extension is not the problem. I wanted to look for pictures originally then I changed the extension. The extension variable is working. The problem is probably with the file path and how it concatenates the Root, wildcard and extension.

Highlighted
Master
Master

Re: Get a list of files

Try putting some trace statements in your script and maybe you can see where it is going wrong.

Highlighted
Contributor II
Contributor II

Re: Get a list of files

This is getting annoying.

Found another example in the documentation http://help.qlik.com/en-US/sense/3.1/Subsystems/Hub/Content/Scripting/ScriptControlStatements/For%20...

Still Not working.

Highlighted
Contributor II
Contributor II

Re: Get a list of files

I might be crazy but I think that the wildcard is not evaluated

Highlighted

Re: Get a list of files

Hi,

try using this approach...

How to use regular expressions

It's a QlikView file, but you could try the same approach in Sense.

Br,

Andrea

Highlighted
Master
Master

Re: Get a list of files

I just ran this code against one of my Data Connections and added a .csv extenstion and it ran and returned all of the files correctly.

I would suggest that you try this code.  Create a data connection to your folder and then change the lib statement to point to the name of the new data connection.

That should work

View solution in original post

Highlighted
Contributor II
Contributor II

Re: Get a list of files

I think that something is missing from that example because it just "loads" from some files and 2 inline tables, but the files are not set in the download section.

Highlighted
Contributor II
Contributor II

Re: Get a list of files

Yes! It finally Worked with a connection.

Created Images Folder Connection then modified the script and all images were loaded. Thanks!

Set vConcatenate = ;

FileList:

LOAD

'' AS SourceFile

AUTOGENERATE 0;

sub ScanFolder(Root)

          for each FileExtension in 'jpg'

          let vThing = Root & '*.' & FileExtension;

                    for each File in filelist(vThing)

                              FileList:

                              LOAD '$(File)' as SourceFile

       AUTOGENERATE 1;

                            

                              Set vConcatenate = Concatenate;

                    next File

          next FileExtension

          for each SubDirectory in dirlist( Root & '\*' )

                    call ScanFolder(SubDirectory)

          next SubDirectory

end sub

Call ScanFolder('lib://Images/') ;