1 Reply Latest reply: Nov 9, 2010 2:30 PM by Miguel Angel Baeyens de Arce RSS

    table name issue in loop to load all files in a folder

    james wynn

      I can not name the table using '$(File)' to populate tblNm

      OR; how should I use the file name to name a table and write a QVD?

       

      // load all data extracts

      for each File in filelist(loadPath &'\*.csv')

      Load '$(File)' as Name;

      // define tblNm

      let pthNm = '$(File)';

      let stNm = index('$(pthNm)','Polo');

      let endNm = index('$(pthNm)','Extract_') + 7;

      let tblNm = mid('$(pthNm)',$(stNm),$(endNm)-$(stNm));

       

      //how do I name the table HERE?

      //tblNm: attempt #1

      //set tablename='$(tblNm)' attempt #2;

      Load *

      FROM

      $(pthNm)

      (txt, utf8, embedded labels, delimiter is ',', msq);

      Store $(tblNm) into $(qvdPath)\$(tblNm).qvd

      (qvd);

      drop table $(tblNm);

      next File

        • table name issue in loop to load all files in a folder
          Miguel Angel Baeyens de Arce

          Hi,

          Since the table name is used only in QlikView and has nothing to do with the actual name of the QVD file, why don't you use the same table name but store it using the name you want? Something like

           

          // load all data extractsfor each File in filelist(loadPath &'\*.csv') // define tblNmlet pthNm = '$(File)';let stNm = index('$(pthNm)','Polo');let endNm = index('$(pthNm)','Extract_') + 7;let tblNm = mid('$(pthNm)',$(stNm),$(endNm)-$(stNm)); Table:Load *FROM$(pthNm)(txt, utf8, embedded labels, delimiter is ',', msq);Store Table into $(qvdPath)\$(tblNm).qvd(qvd);drop table Table;next File


          Hope that helps.