4 Replies Latest reply: Nov 21, 2016 1:50 PM by Joey Lutes RSS

    Qlik Sense loop sub script not finding directories or files

    Joey Lutes

      Hello,

       

      I'm trying to create a list of filenames and directories using methods described here:
      Loop through root directory (including subfolders) and list filenames of *.csv

       

      During Debug, I find that the variables 'SubDirectory' and 'FoundFile' are producing <NULL> which subsequently doesn't create a table.

       

      There are indeed many directories which each contain multiple csv files in the specified location.  I have changed the location of them to a new directory and re-pointed the path as well with the same results.  I've tried with and without '\' in the CALL statement.

      No errors are produced.

       

      Any advice?

      sub GetCSVFileNames(Root)

          for each FoundFile in filelist( Root & '\*.csv')

              FileList:

                  Load

                       filename('$(FoundFile)') as FileName,

                       filedir('$(FoundFile)') as FileDir

                       Autogenerate(1);

          next FoundFile

          for each SubDirectory in dirlist( Root & '\*' )

              call GetCSVFileNames(SubDirectory)

          next SubDirectory

      end sub

       

      Call GetCSVFileNames('C:\datafiles') ;

       

      gwassenaar

      This is related to Loop Through Directory Structure to load data however I'm trying to start by simplifying things.

       

      Thank you!