Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

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;

Tags (1)
2 Replies
SunilChauhan
Esteemed Contributor

Re: Store in variable path with variable file name

try this

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

or

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

hope this helps

Not applicable

Re: Store in variable path with variable file name

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.

Community Browser