2 Replies Latest reply: Sep 19, 2012 7:27 AM by Gaurav Mithaiwala RSS

    How to read from subfolders?

    Leandro Duarte

      Hi Colleagues,

       

      I'm looking for some solution to ready multiple folders as data source (txt or excel)

       

      Basically I need to create a load statement where I ready from all the folders below?

       

      Folder 1\SubFolder 1

      Folder 1\SubFolder 2

      Folder 1\SubFolder 3

       

      inside the folder I have a generif file name it means I should read all files with .xls extension

       

      Thanks in advance,

      Leandro Duarte

        • Re: How to read from subfolders?
          whiteline _

          Hi.

          Look at help, 'foreach' statement. There is an example.

          • Re: How to read from subfolders?
            Gaurav Mithaiwala

            Hi Leandro,

             

            take a look at below script, this might help you.

             

            SUB doDir (dir)

                      FOR EACH file in filelist('$(dir)' &  '\*.qvw')

                                     files:

                                     LOAD

                   x,

                   y

                   from xyz;

                      NEXT

             

              FOR EACH subdir in dirlist( '$(dir)' & '\*' )

                                  CALL doDir('$(subdir)')

                      NEXT

             

            END SUB

             

            FOR EACH subdir in dirlist( '.' & '\*' )

              CALL doDir('$(subdir)')

            NEXT

             

            Regards,

            Gaurav