Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

load list of file names within a folder

Hi all,

I have a folder with several files within it. I want to load a list of the files into Qlikview.

The script I'm using so far is simply this:

Load

     Filepath() as Filepath

From C:/foldername/*;

What is happening is that qlikview is loading in a list of some of the files, but not all of the files in the folder.

Any help please?

Thanks

8 Replies
gajapathy74
Creator II
Creator II

Hi,

Please refer the following.

http://community.qlik.com/message/287438#287438

Not applicable
Author

Thanks for the links but I don't understand the syntax highlighted and how to adapt it to my own computer.

for each File in FileList('$(sPathResources)\*.txt')

          File:

          LOAD *, FileBaseName() as FileName

          FROM [$(File)]

          (txt, codepage is 1252, embedded labels, delimiter is spaces);

     

NEXT File

gajapathy74
Creator II
Creator II

Hi,

You need to specify the value for sPathResources. for example if you have the files in "data" folder under C drive then

Set sPathResources = 'C:\Data';

$(File) is derived from the For Each loop.

hope this helps.

Not applicable
Author

This is not working. If I use the * in the load script I get an error saying 'Field names must be unique within table' and I end up with loads of synthetic keys.

Here is my exact script:

For each File in FileList('G:\Over Ground Assets\Microfilm Drawings\Original\CD1\Bundle 01\*')

File:
Load *, FileBaseName() As FILENAME

From [$(File)] (txt, codepage is 1252, embedded labels, delimiter is spaces);

Next File

gajapathy74
Creator II
Creator II

make sure that you have same set of field (data) in each file.

Not applicable
Author

Hi. No, please don't misunderstand. These files are not data files I want to load into Qlikview. I want to generate a list of files in a folder, in Qlikview. The files themselves are image files (Tiff's).

Not applicable
Author

I had a similar need, and was able to create a table listing the file names using the following script:

FileList:

load * Inline [

  Sort,FileName

];

let iter = 0;

for each File in FileList('Filepath\*.*')

  let iter = $(iter) + 1;

  trace iter = $(iter);

  let vFileName = Replace('$(File)', 'Filepath\', null());

  trace vFileName = $(vFileName);

  [_t]:

  ADD load * Inline [

  Sort,FileName

  '$(iter)','$(vFileName)'

  ]

  ;

NEXT File

let File = null();

let iter = null();

Anonymous
Not applicable
Author

Hi Dan,

You said that you only want to load the file names, so you shouldn't use the asterisk, which loads all fields in a file. The error you got is usually from loading a file with the two occurrences of the same field name or loading a file and then trying to add a field name that already exists in the file.