Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

vchuprina
New Contributor II

How load another files from folder?

I use in my script following code:

let vDataFolder = '\Clients\Current';

FOR each vFile in Filelist ('$(vDataFolder)\Data*.xls')

In current folder I have four files, but parser loads only first file.

Also I add 'Next vFile' in the end of script, but this didn't help.

1 Solution

Accepted Solutions
MVP
MVP

Re: How load another files from folder?

Hi

The For Each must be associated with a Next to mark the end of the loop.

FOR each vFile in Filelist ('$(vDataFolder)\Data*.xls')

    

   Data: 

   LOAD .... FROM $(vFile) (biff, ...)


Next


If the files have identical field lists, they will auto-concatenate into a single result table.


HTH

Jonathan



Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
5 Replies
datanibbler
Esteemed Contributor

Re: How load another files from folder?

Hi,

can you identify any difference between your files? Do their names all begin with that word "Data" - the rest shouldn't matter as you have an * - and are they all in .xls format?

That code you have should work. When you go through it in the Debugger, does that vDataFolder evaluate to a correct file_path?

Best regards,

DataNibbler

gabriel_kirst
Contributor III

Re: How load another files from folder?

Hi!

It should work:

SET vDataFolder = 'C:\Clients\Current';

For each vFile in filelist ('$(vDataFolder)\Data*.xls')

  [File]:

  LOAD *

  FROM

  [$(vFile)]

  (ooxml, embedded labels, table is Plan1);

Next vFile;

Hope it helps.

Gabriel

MVP
MVP

Re: How load another files from folder?

Hi

The For Each must be associated with a Next to mark the end of the loop.

FOR each vFile in Filelist ('$(vDataFolder)\Data*.xls')

    

   Data: 

   LOAD .... FROM $(vFile) (biff, ...)


Next


If the files have identical field lists, they will auto-concatenate into a single result table.


HTH

Jonathan



Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
vchuprina
New Contributor II

Re: How load another files from folder?

Yes, they have the same extansion and all names begin from "Data". Maybe reason, that I have different "sub-load" for each these files, because they have the same data, but this data in different columns.

Scripts structure:

First (1) TAB :

let vDataFolder = '\Clients\Current';

FOR each vFile in Filelist ('$(vDataFolder)\Data*.xls')

(2)

IF (x= a) then

Load Data


(3)

Else if (x= b) then

Load Data

(4)

Else  then

Load Data


(5)

NEXT vFile;



datanibbler
Esteemed Contributor

Re: How load another files from folder?

Hi,

is that IF THEN structure you have inside your loop also properly closed with an ENDIF?

The columns should actually not matter if you load via field_names and the names are the same between the files.

Best regards,

DataNibbler

Community Browser