Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

FileName from a network path

Hi,

I have written a piece of code to loop through all the files in a network path and save the file names into a qvd. The script is like this

For wach File in FileList($(DirPath))

     Load

          FileName($(File)) as FileName,

          Today() as FileLoadedOn

     Autogenerate 1;

Next File;

$(DirPath) has "\\server-01\folder1\File_*.qvd" to get all the qvd files starting with File_.

When this code is executed, i am getting the error saying "Field not found - <\\server>

Capture.JPG

How to resolve this error ?

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Don't add any arguments to FileName(). Just FileName() as Filename. But that only works if you actually load from a file. You don't use a FROM clause so you're only generating a single record. You can't use FileName() in that case.

For each File in FileList($(DirPath))

     Load

          '$(File)' as FileName,

          Today() as FileLoadedOn

     Autogenerate 1;

Next File;

If you actually want to load the data from the files then use something like this:

For wach File in FileList($(DirPath))

     Load

          *

          FileName() as FileName,

          Today() as FileLoadedOn

     FROM

          [$(File)] (...whatever is appropriate here...)

     ;

Next


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks Gysbert, that resolved the error. But the FileName column in table is showing as null. Am i missing anything ?

Deepika