Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
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
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Replace


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


with

 

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


talk is cheap, supply exceeds demand

View solution in original post

6 Replies
Not applicable
Author

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

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

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
Author

Hi,

How do I exclude name that contain REDO?

Thanks,

Aji Paul

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Replace


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


with

 

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


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks for the update! Will update you soon

Not applicable
Author

Hi Thank you very much!

It worked awesome!