Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

loading contents of multiple files

hello have multiple files in a subdirectory that I have to load.

Their names can be ONLY 'ABC' OR 'ABC.myfile'. I need to create a loop to load the info from these files (their content are all the same).

Can you assist please? Not sure how to write the script.

Thanx

4 Replies
Not applicable

loading contents of multiple files

i just noticed that one of the fields I'm loading, does not have a field name in Excel (embedded header).To add to the above discussion, how can I dinamically give a field name (taken into consideration that all the other fields DO have embedded field names). I could put them in manually, but there are many files that I need to load.Thank you

Not applicable

loading contents of multiple files

Hi,

You can try using a Do..While statement for loading multiple fles from the same directory....

Let file_counter=0;

for file_counter =1

     do

while file_counter<n //n is the number of files in your sub directory

Load * from file$(file_counter).xlsx;

let file_counter=file_counter+1;

loop

Hope that helps.

Regards,

-Khaled.

//Let a=0;

//Let i=0;

//do while i<4

//a=a+1

//loop   

Not applicable

loading contents of multiple files

Thank you Khaled, Problem is, I have multiple files in the subdirectory (and I dont always know how many). I would just like to load all the files that contain 'HIST' in the file extension....it might be 'HIST001' and 'HIST002'.

flipside
Valued Contributor II

loading contents of multiple files

You can use wildcards to select from multiple files, similar to ...

LOAD Filename(),

@1 as Data1,

@2 as Data2

FROM

[*.hist*]

(txt, codepage is 1252, no labels, delimiter is '|', msq, header is 1 lines);

Regarding the missing field name, if you try to load it as embedded labels you will get an error due to the missing column identifier.  If you say all the files are same structure, then load it with "no labels" and skip the first line (the header, shown as "header is 1 lines" above) and alias the fields such as @1 as Data1, @2 as Data2.

flipside