Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
prees959
Contributor II

For...Next Loop through folder error

Hi,

I'm using the following script to convert a load of CSV files to QVD

for each file in FileList('$(vFolder)datafile*.csv')

     

  Daily:

  LOAD *

  FROM $(file)

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

  Let vPathFileDate = Date(Date#(left(subfield(subfield('$(file)','\', -1), '_', -1), 8), 'YYYYMMDD'), 'YYYY_MM_DD'); 

 

  STORE Daily INTO ..\..\Daily\Daily_$(vPathFileDate).QVD;

 

  DROP TABLE Daily;

  Next file;

It is running fine until it gets tot the end and I get a 

Script line error:

Next File

Can anyone help....?

Thanks,

Phil

Tags (1)
4 Replies
mwoolf
Honored Contributor II

Re: For...Next Loop through folder error

Try removing the semicolon after next file

prieper
Honored Contributor II

Re: For...Next Loop through folder error

Do not think that the semicolon makes the difference.

Would rather check the spelling and/or rename the variable to vFile or the like

Partner
Partner

Re: For...Next Loop through folder error

Try

Let vPathFileDate = Date#(Date#(left(subfield(subfield('$(file)','\', -1), '_', -1), 8), 'YYYYMMDD'), 'YYYY_MM_DD');

Re: For...Next Loop through folder error

It runs just fine for me and I made no changes. You may have different values in your variables and/or different folder permissions.

IMHO this is an ideal case to use the QlikView Script Debugger. After each statement, it lets you check all variables vlaues before you use them (e.g. vFolder, file, and especially vPathFileDate)