Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

reddys310
Honored Contributor II

Re: Load all tables from directory

Hi Walter,

Check this out:

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

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

Thanks,

Sangram.

6 Replies
homersimpson
Contributor II

Re: Load all tables from directory

Hi Sangram,

there is an error for "FileList". I can´t find "FileList" in the documentation https://help.qlik.com/de-DE/sense/1.1/Subsystems/Hub/Content/Scripting/FileFunctions/FileFunctionsIn...

Is this only for Qlikview? I´m using Qlik Sense.

2016-05-04_10h20_44.jpg

regards,

René

undergrinder
Valued Contributor II

Re: Load all tables from directory

Hi Walter,

What is the error message?

G.

undergrinder
Valued Contributor II

Re: Load all tables from directory

The FileList expression could be reserved. Have you tried other tablename?

homersimpson
Contributor II

Re: Load all tables from directory

Mhhh, there is no error message, it´s only red.

MVP
MVP

Re: Load all tables from directory

It could be caused by the $(vConcatenate) expansion below. It may just be the syntax checker and may not be a real error. Using variables like this also breaks the QV scruipt editor syntax check, but they run normally in spite of the error indicated in the syntax check.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
undergrinder
Valued Contributor II

Re: Load all tables from directory

It's strange. Doesn't say the data load editor anything, only error occured?

--

I think you can make it more easier that code, so easier to debug.

I would omit the second for each about file extension, and change the filelist( Root & '\*.' & FileExtension) to filelist( Root & '\*.csv), or add if


if right('$(File)',3)='csv' then

     Load ....

end


G.

Community Browser