Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Load all tables from directory

Hi,

i want to load always all tables from a directory, even if there new tables or tables were deleted.

This is an example for a folder structure:

MainFolder

       SubFolderr1

                      File1

                      File2

       SubFolder2

                      File3

                      File4

       SubFolder3

                      File5

                      File6

How can i load always all tables from MainFolder regardless of new filename´s or files wich were deleted?

regards,

Fritz

13 Replies
afurtado
Partner Ambassador/MVP
Partner Ambassador/MVP

Walter,

maybe something like

sub DoDir (Root)

   for each Ext in 'qvw', 'qva', 'qvo', 'qvs', 'qvc', 'qvd'

      for each File in filelist (Root&'\*.' &Ext)

     

         FileLoad:

         LOAD

            '$(File)'             as Name,

            FileSize( '$(File)' ) as Size,

            FileTime( '$(File)' ) as FileTime

         autogenerate 1;

        

         trace Loading file $(Dir)/$(File) ;

         LOAD * FROM [$(File)] (qvd);

      next File

   next Ext

  

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

      call DoDir (Dir)

   next Dir

end sub

call DoDir ('C:\tmp\QVD');

furtado@farolbi.com.br
afurtado
Partner Ambassador/MVP
Partner Ambassador/MVP

sample model....

furtado@farolbi.com.br
agilos_mla
Partner - Creator III
Partner - Creator III

Take a look at Rob's QlikView Components : GitHub - RobWunderlich/Qlikview-Components: A library for common Qlikview Scripting tasks

a call to the sub Qvc.ListFiles will do the job.

Hth,

Michael

vikasmahajan

loop through to load all files from a folder and its subfolders?

HTH

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
Anonymous
Not applicable
Author

i can´t find "filelist" in the documenation https://help.qlik.com/de-DE/sense/1.1/Subsystems/Hub/Content/Scripting/FileFunctions/FileFunctionsIn...

I´m working with Qlik Sense for Desktop. Is this ok or an error?

Must i use an alternative command?

Because the script doesn´t run the red code:

Set vConcatenate = ;

sub ScanFolder(Root)

          for each FileExtension in 'csv'

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

                              FileList:

                              $(vConcatenate)

                              LOAD *, '$(FoundFile)' as SourceFile

                              FROM [$(FoundFile)] (txt, codepage is 1252, embedded labels, delimiter is ',', msq, header is 2 lines);

                              Set vConcatenate = Concatenate;

                    next FoundFile

          next FileExtension

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

                    call ScanFolder(SubDirectory)

          next SubDirectory

end sub

Call ScanFolder('C:\Users\hic\Documents\2012\Work\QV Apps\DoDir') ;

regards,

René

undergrinder
Specialist II
Specialist II

It can be caused by the FileExtension variable.

Try

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

instead of

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

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

G.

Anonymous
Not applicable
Author

I found the solution:

https://help.qlik.com/en-US/sense/1.1/Subsystems/Hub/Content/LoadData/FileSystemAccessRestriction.ht...

For security reasons, Qlik Sense in standard mode does not support absolute or relative paths in the data load script or functions and variables that expose the file system.

However, since absolute and relative paths were supported in QlikView, it is possible to disable standard mode and use legacy mode in order to reuse QlikView load scripts.

https://help.qlik.com/en-US/sense/1.1/Subsystems/Hub/Content/LoadData/DisableStandardMode.htm

regards,

René

undergrinder
Specialist II
Specialist II

Oh yes, I didn't noticed the absolute path.

Create a lib connection to that directory, and will work.

G.

Anonymous
Not applicable
Author

How can i create a lib connection to that directory?

I got an error now

2016-05-04_13h16_06.jpg

regards,

René