Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

gshockxcc
Contributor

For each File error

This code was working when initially written.  However the “File” variable does not initialize when run.  This is from an incremental load script, and it has been run previously.  I have changed to a different project using the same incremental load script.  The 'File' variable still has a value from a previous project, and I am not able to clear it.

I have also used

Let File = Null;

and

Let File = Null();

to initialize the variable, but it always keeps the '<null>' value, and never initializes in the script.


I have tried to use a new variable, 'File1' and it will also not initialize, meaning it's always '<null>' when running the load script.


FOR EACH File IN FILELIST ($(FilePath) & '*' & Str)
FileNameTable:
LOAD *,FileName() As FileName,
num(FileTime()) as FileTime
From [$(FilePath)*$(Str)](txt, utf8, embedded labels, delimiter is ',', msq)
Where round(num(FileTime()),0.000001) = round($(vMaxDate),0.000001) ;

NEXT File 

Any help would be GREATLY appreciated.

Thanks,

Tags (1)
1 Solution

Accepted Solutions

Re: For each File error

I assume what this means is that

($(FilePath) & '*' & Str)

does not point to a valid path. Look in the document log to see what is being substituted in the Filelist().

Also the

From [$(FilePath)*$(Str)](txt, utf8, embedded labels, delimiter is ',', msq)

does not look correct. When your filelist works, you should be loading from $(File) like:

From [$(File)] (txt, utf8, embedded labels, delimiter is ',', msq)


-Rob

3 Replies
MVP
MVP

Re: For each File error

I would look into the evaluation of your FILELIST.

What's the definition of FilePath and Str? If you run the script in the debugger, how does this line shows up?

Re: For each File error

I assume what this means is that

($(FilePath) & '*' & Str)

does not point to a valid path. Look in the document log to see what is being substituted in the Filelist().

Also the

From [$(FilePath)*$(Str)](txt, utf8, embedded labels, delimiter is ',', msq)

does not look correct. When your filelist works, you should be loading from $(File) like:

From [$(File)] (txt, utf8, embedded labels, delimiter is ',', msq)


-Rob

gshockxcc
Contributor

Re: For each File error

Rob,

     Sorry for the delay in responding.  You're correct.  The 'Filelist' was not generating the correct path.  It has to do with how I was specifying the path using variables and '*.' instead of just '*'.  I moved the '.' inside of the variable where I specified the file extension, and it works great.  I also removed the $() around the FilePath.

FOR EACH File IN FILELIST (FilePath & '*' & Str)

Thanks,

Community Browser