Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
reddy-s
Master II
Master 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
Anonymous
Not applicable

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
Specialist II
Specialist II

Hi Walter,

What is the error message?

G.

undergrinder
Specialist II
Specialist II

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

Anonymous
Not applicable

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

jonathandienst
Partner - Champion III
Partner - Champion III

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
Specialist II
Specialist II

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.