Skip to main content
Announcements
Save $600 on Qlik Connect registration! Sign up by Dec. 6 to get an extra $100 off with code CYBERSAVE: REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
gshockxcc
Creator
Creator

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,

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

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

View solution in original post

3 Replies
swuehl
MVP
MVP

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?

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

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
Creator
Creator
Author

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,