Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
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
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.
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.
Try putting some trace statements in your script and maybe you can see where it is going wrong.
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.
I might be crazy but I think that the wildcard is not evaluated
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
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
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.
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/') ;