Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Become an analytics expert with Qlik's new 15 week course: Applied Data Analytics using Qlik Sense. READ MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to load all files from directory


Hi Friends

I have three folders in D drive each having some text files.

I want to run load statement to load all the text files from folders.

Thanks

9 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Try like this

Data:

LOAD

*

FROM Folder1\*.txt;

Concatenate(Data)

LOAD

*

FROM Folder2\*.txt;

Concatenate(Data)

LOAD

*

FROM Folder3\*.txt;

Regards,

Jagan.

Not applicable
Author

Thanks Jagan

But the format for all text file are same so I want to load all text files at a go from all folders.

Thanks


simondachstr
Luminary Alumni
Luminary Alumni

Try something like:

for each Dir in dirlist (Root&'\*' )

Load '$(Dir & '\*.txt')'   <- not sure if this statement works

next Dir

jagan
Luminary Alumni
Luminary Alumni

Hi Pavan,

Then you have to loop the folders using For loop or if it is just 3 folders then you can use above script.

FOR Each Dir in dirlist (Root&' \*' )

Data:

LOAD

*

FROM $(Dir)\*.txt;

NEXT Dir

Regards,

Jagan.

mjayachandran
Creator II
Creator II

You can also do it like,

Config:

Load * inline [

path,

'c:\'

'D:\'

'c:\Data\'

];

For i=0 to noofrows('Config')-1

let path=peek('path',0,'Config');

Test:

Load

......................

your fields

.....................

From

$(path)*.txt (txt, codepage is 1252, no labels, delimiter is ' ', msq);

In the config you can define all the path u want to load

Not applicable
Author

Jagan I am using the code. The highlighted is my path name where all the text files are there. Can you send me the code please

Load *

FROM

[D:\test\9_30\9_30\*.txt]

Not applicable
Author

Jagan

Could you please explain the code how it works.

Thanks

mjayachandran
Creator II
Creator II

Config:

Load * inline [

path, Location

Path1, 'D:\test\9_30\9_30\' ,

Path2, 'D:\test\9_31\9_31\'

];

For i=0 to NoOfRows('Config')-1

let path= Peek('Location', $(i), 'Config');

Table:

Load

*

From $(path)*.txt (txt, codepage is 1252, no labels, delimiter is ' ', msq);

Next i

Drop Table Config;

jagan
Luminary Alumni
Luminary Alumni

Hi,

The below code loops through all the folders in the given root path using FOR EACH loop and loads all the text files in each folder, we have used wildcard characters *.txt to load only txt files.

SET Root = 'D:\test\9_30\9_30';

FOR Each Dir in dirlist (Root&' \*' )

Data:

LOAD

*

FROM $(Dir)\*.txt (txt, codepage is 1252, no labels, delimiter is ' ', msq);

NEXT Dir