Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
vchuprina
Specialist
Specialist

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.

Press LIKE if the given solution helps to solve the problem.
If it's possible please mark correct answers as "solutions" (you can mark up to 3 "solutions").
1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

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

View solution in original post

5 Replies
datanibbler
Champion
Champion

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

Anonymous
Not applicable

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

jonathandienst
Partner - Champion III
Partner - Champion III

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

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;



Press LIKE if the given solution helps to solve the problem.
If it's possible please mark correct answers as "solutions" (you can mark up to 3 "solutions").
datanibbler
Champion
Champion

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