Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
homersimpson
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
Not applicable

Re: Load all tables from directory

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');

afurtado
Not applicable

Re: Load all tables from directory

sample model....

agilos_mla
Not applicable

Re: Load all tables from directory

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
Not applicable

Re: Load all tables from directory

homersimpson
Not applicable

Re: Load all tables from directory

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
Not applicable

Re: Load all tables from directory

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.

homersimpson
Not applicable

Re: Load all tables from directory

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
Not applicable

Re: Load all tables from directory

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

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

G.

homersimpson
Not applicable

Re: Load all tables from directory

How can i create a lib connection to that directory?

I got an error now

2016-05-04_13h16_06.jpg

regards,

René