Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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

loop through to load all files from a folder and its subfolders?

Hi all,
This is my folder structure
MainFolder
       20150102
                      File1a.txt
                      File2ab.txt
                      File3.txt
       20150103
                      File1ab.txt
                      File2a.txt
                      File3ab.txt
                      File4.txt
       20150104
                      File3a.txt
                      File5.txt
                      File6.txt
I'm trying to use a Loop function but each text file has a different parameter (comma, space, dash, etc. ). I'm also trying to use a wildcard.
FROM

(
txt, codepage is 1252, no labels, delimiter is '|', msq);
my loop statement is written similar to this one but fot TXT file instead of CSV.
how do I combine different parameter, scan folders and subfolder, HELP!!
Thanks in advance
1 Solution

Accepted Solutions
simone_spanio
Not applicable

Re: loop through to load all files from a folder and its subfolders?

But do you know which files have a specific separator? Can you identify them by the filename?

S.

6 Replies
Not applicable

Re: loop through to load all files from a folder and its subfolders?

Not applicable

Re: loop through to load all files from a folder and its subfolders?

I used that post as a guide but I have specific folder name that I need to search by.


set Concatenate=;     
// subroutine
sub ScanFolder(Root)
for each Ext in 'File1a.txt' // use this to identify file names to load but I can't use the wildcard to pull all File1*
for each FoundFile in filelist(Root & '\*' & Ext)
FileList:     

$(Concatenate)
load *
from
[$(FoundFile)](txt, utf8, no labels, delimiter is '\t', msq, no eof); // my load has different parameters depending on the file name.

set Concatenate = concatenate;
next FoundFile
next Ext

for each SubDirectory in dirlist(Root&'\*')
call ScanFolder(SubDirectory)
next SubDirectory
end Sub

C
all ScanFolder('C:\');

simone_spanio
Not applicable

Re: loop through to load all files from a folder and its subfolders?

But do you know which file has a specific separator? For example: *1*.txt has comma, *2* has slash, etc...?

You could try make several loop, one for type of separator

set Concatenate=;     
// subroutine
sub ScanFolder(Root)
for each Ext in 'File1a.txt' // use this to identify file names to load but I can't use the wildcard to pull all File1*
for each FoundFile in filelist(Root & '\*' & Ext)
FileList:     

$(Concatenate)
load *
from
[$(FoundFile)](txt, utf8, no labels, delimiter is '\t', msq, no eof); // my load has different parameters depending on the file name.

set Concatenate = concatenate;
next FoundFile
next Ext

for each SubDirectory in dirlist(Root&'\*')
call ScanFolder(SubDirectory)
next SubDirectory
end Sub


sub ScanFolder_2(Root)
for each Ext in 'File1a.txt' // use this to identify file names to load but I can't use the wildcard to pull all File1*
for each FoundFile in filelist(Root & '\*' & Ext)
FileList:     

$(Concatenate)
load *
from
[$(FoundFile)](txt, utf8, no labels, delimiter is ',', msq, no eof); // my load has different parameters depending on the file name.

set Concatenate = concatenate;
next FoundFile
next Ext

for each SubDirectory in dirlist(Root&'\*')
call ScanFolder(SubDirectory)
next SubDirectory
end Sub


C
all ScanFolder('C:\');

Call ScanFolder_2('C:\');


etc...


S.

Not applicable

Re: loop through to load all files from a folder and its subfolders?

Yes.
I'm trying this but only one Loop is working.

simone_spanio
Not applicable

Re: loop through to load all files from a folder and its subfolders?

But do you know which files have a specific separator? Can you identify them by the filename?

S.

Not applicable

Re: loop through to load all files from a folder and its subfolders?

yes. I have all specific separator.