Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
sagarkharpude
Creator III
Creator III

Load data from specific files from specific folders in the script

Hi Guys,

I want to load data from specific log files(*system*) from multiple specific folders like Folder 1, Folder 4,  Folder 6. Could you please tell me the efficient/best way? 

For e.g. 

Load *

from Path\Folder N/*system*.log

(txt, utf8, embedded labels, delimiter is '\t', msq);

 

Thanks,

Sagar

 

Labels (2)
8 Replies
edwin
Master II
Master II

you can use the for next loop:
For..next ‒ QlikView

 

 

For vCounter = 1 to 5
Load *
from Path\Folder $(vCounter)/*system*.log
(txt, utf8, embedded labels, delimiter is '\t', msq);
Next 

 

 

manoranjan_d
Specialist
Specialist

How to make vcounter = 1 to 5 static  to dynamic?

edwin
Master II
Master II

what is your business rule to determine N in your original code?  if the folders are finite then its a finite number.  if not then you need a different approach.  so it depends you need to define that so others can advise you

edwin
Master II
Master II

if you dont know the number of subfolders then you will need a nested loop:
List folders within a directory - Qlik Community - 88811

your outer loop will give you the folder name so you don't need to use folder$(vcount).  you will have a variable that stores the folder name so use that in your inner loop

For each vSubDir in dirlist( 'D:\Backup\*' )
  for each vFile in [$(vSubDir)\*system*.log]
     Load *
     from [$(vSubDir)\$(File)]
     (txt, utf8, embedded labels, delimiter is '\t', msq);
  next vFile
Next vSubDir

//you just need to experiment with this part: 
// from [$(vSubDir)\$(File)]
//you will see this in your log
sagarkharpude
Creator III
Creator III
Author

Folder numbers are not sequential. It’s like Folder 1, 4 and 6. 
can I maintain one inline table of required folders  name only? So it will be easier to maintain. 

edwin
Master II
Master II

you can conrol which folder to be processed in the phrase 

 in dirlist( 'D:\Backup\*' )

you can use relative paths

sagarkharpude
Creator III
Creator III
Author

Can you please tell me how to pick up certain folders? 

edwin
Master II
Master II

use your pattern:

'c:\path\folder *'

from your sample this is what you were using so just use that in the directory list function