Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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;

2 Replies
SunilChauhan
Champion
Champion

try this

STORE File INTO $(sPathQVDBase) $(NewFileName).qvd (qvd);

or

STORE File INTO '$(sPathQVDBase)' &  '$(NewFileName)'.qvd (qvd);

hope this helps

Sunil Chauhan
Not applicable
Author

Hi SK. Thanks for your reply. However, it didn't work. Apparently putting both the path and filename as variable is just not being done in QV. I have done a workaround by moving the files instead after storing the tables in QVD.