Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
prees959
Creator II
Creator 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

4 Replies
m_woolf
Master II
Master II

Try removing the semicolon after next file

prieper
Master II
Master II

Do not think that the semicolon makes the difference.

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

nsetty
Partner - Creator II
Partner - Creator II

Try

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

Peter_Cammaert
Partner - Champion III
Partner - Champion III

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)