2 Replies Latest reply: Nov 14, 2012 3:13 AM by Ezreen Sharifudin RSS

    Store in variable path with variable file name

      Hi.

      I was trying to list out all the .tab files in a folder, and store the files as .qvd with the same name. Hence, I tried to take the FileName from the list of files. I failed to store the .qvd file in a separate folder with the same name as the .tab file.

      I have specified variables for the folder paths as the script is needed to run on a schedule basis by the power users with 15 different files.

       

      Can anybody point out where my mistake was?

       

      sPathBase = 'D:\QlikView\Project\';
      sPathQVDBase = (sPathBase) & '02_QVDGenerators\QVD\L1_Base\';
      sPathQVDApp = (sPathBase) & '02_QVDGenerators\QVD\L2_Transform\';
      sPathResources = (sPathBase) & '01_Resources\';
      
      sub Dodir(Root)
       for each FileExtension in 'tab'
        for each FoundFile in filelist( Root & '\*.' & FileExtension)
         let FoundFile = PurgeChar(FoundFile , Chr(39));  
         FileList:
         load '$(FoundFile)' as Filename, 
         subfield('$(FoundFile)','\') as Name
         Autogenerate(1);
        next FoundFile
       next FileExtension
      end sub
      call DoDir('D:\QlikView\RetailFinance\01_Resources');
      
      NewFileName = Name
      
      //Load from tab files and store into qvd files
      File:
      LOAD *
      FROM [$(FileName)]
      (txt, codepage is 1252, embedded labels, delimiter is spaces);
      
      STORE File INTO $(sPathQVDBase)$(NewFileName).qvd (qvd);
      
      drop table File;