2 Replies Latest reply: Feb 15, 2017 3:56 PM by Vladimir Komarov RSS

    Script Help

    Mark Ritter

      I am not quite sure what this code is doing?

      The situation is that I have a folder that contains many csv files.  Basically one for each day. 

       

      Here is the basic script that exists.

       

      EmployeeMaster:

      LOAD *

      FileName()

      FROM

      [lib://QVS-1 DEV/External Data\EmployeeMaster\EmployeeMaster*.csv]

      (txt, codepage is 1252, embedded labels, delimiter is ',', msq);

      Store EmployeeMaster into (QVD file)

       

      Does this code loop through all of the csv files in this folder and concatenate the data into the QVD?

       

      If that is the case is this the optimal way to do this?

       

      What is the filename() function doing in this case?

        • Re: Script Help
          Sunny Talwar

          That is exactly what it is doing. Grabbing each file and storing all its data along with the file name (FileName() function returns the name of the file. For example if you EmployeeMaster02152017.csv, then this is the value which will be stored in FileName() field for all rows from this csv file.

          • Re: Script Help
            Vladimir Komarov

            Looks like you are trying to extract the full names of EmployeeMaster*.csv files from External Data\EmployeeMaster\ folder....

             

            Another option is to use FileList:

             

            For each vFile in FileList('C:\path\*.txt')

                      Load ... From [$(vFile)] ;

            Next vFile

             

             

            Which is identical to

            Load ... From [C:\path\*.txt] ;