Skip to main content
Announcements
Announcing Qlik Talend® Cloud and Qlik Answers™ to accelerate AI adoption! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to fetch data from un known file(s)

Hi All,

   In my requirement I will  have a folder and it  will be placed with many files (may be csv or excel) .

How should I design my load script to pull all the file's data (with out knowing file name). Is that possible?

-Jai

5 Replies
prachisangewar
Creator
Creator

Hi,

You need to first read the Names of the files in the folder in your script, and then read the files sequentially by putting the file names in a loop.

Here is the script

/*Get File Names*/

File_Names:

LOAD distinct FileName() AS NAME

FROM

path\*.csv;

/*Loop*/

FOR ID = 0 TO NOOFROWS('File_Names') - 1

LET vNAME = PEEK('NAME',ID,'File_Names');

/*Read the File*/

load *

from path\$vNAME);

next ID;

marcus_sommer

You could use a loop over all folders/files per dirlist/filelist. Here you will find explanations and examples:

For each..next ‒ Qlik Sense

Wildcard data loading (*.blah......)

- Marcus

qlikview979
Specialist
Specialist

Hi follow this steps   as per your requirement

loading .xls and .csv files from same folder

Not applicable
Author

Hi Jai,

Yes, it is possible. Try adding this to your load script and do a reload. Let us know how you get on.

_____________________________________________________

For Each vExt in 'xlsx','csv'

  For Each vFile in FileList('*.$(vExt)')

    If vExt = 'xlsx' Then

    Table1:

  LOAD *

FROM

[$(vFile)]

(ooxml, embedded labels, table is Sheet1);

;

  Else

    Table2:

  LOAD *

FROM

[$(vFile)]

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

   End If

Next

Next

______________________________________________________

Warm regards,

Nish

Not applicable
Author

Hi Jai,

Have you had a chance to look at my reply yet? (it works like a charm on me!)

If my reply does the trick for you, I would appreciate it if you could show your appreciation by marking it as helpful/correct - this is considered as a good practice by Qlik Community

Many thanks,

Nish