Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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;
You could use a loop over all folders/files per dirlist/filelist. Here you will find explanations and examples:
Wildcard data loading (*.blah......)
- Marcus
Hi follow this steps as per your requirement
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
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