Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Loading multiple files

Hi All,

Need some help with loading multiple files form a remote system.

There is a base folder and it has many sub folders.

I need to conditionally load all the files from the lowest level

Ex. C:\CAMP_BASE

        C:\CAMP_BASE\OCT-10

        C:\CAMP_BASE\NOV-10

        C:CAMP_BASE\ARCH        <------------------------ Skip folder

      C:CAMP_BASE\ARCH\\NOV-10\FILE_FOLD1 <- Skip

        C:CAMP_BASE\SOMEOTHER <-------------------Skip folder

        C:\CAMP_BASE\OCT-10\FILE_FOLD1

        C:\CAMP_BASE\OCT-10\FILE_FOLD2

        C:\CAMP_BASE\NOV-10\FILE_FOLD1

        C:\CAMP_BASE\OCT-10\FILE_FOLD1_REDO_T <-------------------Skip folder

       C:\CAMP_BASE\OCT-10\FILE_FOLD1_REDO_T\OCT-10\FILE_FOLD1 <--- Skip

Condition 1 : skip all the folders that do NOT have "-" in the name

Condition 2 : In the next level skip any folder  with a name contains word "REDO"

So that I will end up with the following folders

C:\CAMP_BASE\OCT-10\FILE_FOLD1

   

C:\CAMP_BASE\OCT-10\FILE_FOLD2

  C:\CAMP_BASE\NOV-10\FILE_FOLD1

Any Idea?

Thanks,

Aji Paul.

1 Solution

Accepted Solutions

Re: Loading multiple files

Replace


    if (substringcount('$(SubDirectory)','-')) then


with

 

    if (substringcount('$(SubDirectory)','-') and substringcount('$(SubDirectory)','REDO')=0 ) then


talk is cheap, supply exceeds demand
6 Replies
Not applicable

Re: Loading multiple files

Additional info

These folders may contain many text files and need to load all of them *.txt

C:\CAMP_BASE\OCT-10\FILE_FOLD1

    C:\CAMP_BASE\OCT-10\FILE_FOLD2

   C:\CAMP_BASE\NOV-10\FILE_FOLD1

Re: Loading multiple files

Maybe something like the script below (adapted from Henric's code here):

Set vConcatenate = ;

sub ScanFolder(Root)

    for each FileExtension in 'txt'

        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 & '\*' )

         if (substringcount('$(SubDirectory)','-')) then

             call ScanFolder(SubDirectory)

         end if

    next SubDirectory

end sub

Call ScanFolder(' C:\CAMP_BASE') ;


talk is cheap, supply exceeds demand
Not applicable

Re: Loading multiple files

Hi,

How do I exclude name that contain REDO?

Thanks,

Aji Paul

Re: Loading multiple files

Replace


    if (substringcount('$(SubDirectory)','-')) then


with

 

    if (substringcount('$(SubDirectory)','-') and substringcount('$(SubDirectory)','REDO')=0 ) then


talk is cheap, supply exceeds demand
Not applicable

Re: Loading multiple files

Thanks for the update! Will update you soon

Not applicable

Re: Loading multiple files

Hi Thank you very much!

It worked awesome!

Community Browser