Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Extracting Data

Hi friends,

i am creating a Report using last two years data.

here my problem is am having the source files in daily basis and storing in different folders date wise.

Capture.PNG

i have to extract all , i have to take one by one? or is there any better way to extract all these files?

suggest me please...

thanks,

sowmya

1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

Try this,

Sub ScanFolder(Root)  
For Each FoundFile in Filelist( Root & '\*' & '.xlsm')  
 
If '$(FoundFile)' Like '*Stratification Audit*' Then
    Data:
   
Load  *,
   
Subfield('$(FoundFile)','\',SubStringCount('$(FoundFile)','\')+1) as FileName
   
FROM [$(FoundFile)] (ooxml, embedded labels, header is 8 lines, table is [Stratification Audit]);
 
End If 

Next FoundFile 

 

// Sub folder       
     For Each SubDirectory in Dirlist( Root & '\*' )
      
Call ScanFolder(SubDirectory)
  
Next SubDirectory


End Sub  


Call ScanFolder('P:\Banking\03 Reporting\Source Files\QRM Output\2016') ;

View solution in original post

6 Replies
tamilarasu
Champion
Champion

Hi Sowmya,

Check the below thread.

Question About Loop (Foreach)

Not applicable
Author

my folder structure:

D:\ Report \Sensi \Archive \Archive(YYYYMMDD) \IR Dump \myfile.csv

Not applicable
Author

Capture3.PNG

hi, i am getting the above error, my code is below.

SUB scanfolder(root)

for each fileextension in 'xlsm'

    For Each FoundFile in Filelist( Root & 'P:\Banking\03 Reporting\Source Files\QRM Output\2016\*\*\*Stratification Audit Report v2.xlsm') 

              if WildMatch('$(FoundFile)','*Stratification Audit*')  then

                Data: 

                 Load  *

                       FROM [$(FoundFile)] (ooxml, embedded labels, header is 8 lines, table is [Stratification Audit]);

                    ENDIF

                      

                    Next FoundFile 

          Next FileExtension 

     // Sub folder        

          For Each SubDirectory in Dirlist( Root & '\*' ) 

                    Call ScanFolder(SubDirectory) 

          Next SubDirectory 

         

End Sub 

 

Call ScanFolder('P:\Banking\03 Reporting\Source Files\QRM Output\2016') ; 

tamilarasu
Champion
Champion

Try this,

Sub ScanFolder(Root)  
For Each FoundFile in Filelist( Root & '\*' & '.xlsm')  
 
If '$(FoundFile)' Like '*Stratification Audit*' Then
    Data:
   
Load  *,
   
Subfield('$(FoundFile)','\',SubStringCount('$(FoundFile)','\')+1) as FileName
   
FROM [$(FoundFile)] (ooxml, embedded labels, header is 8 lines, table is [Stratification Audit]);
 
End If 

Next FoundFile 

 

// Sub folder       
     For Each SubDirectory in Dirlist( Root & '\*' )
      
Call ScanFolder(SubDirectory)
  
Next SubDirectory


End Sub  


Call ScanFolder('P:\Banking\03 Reporting\Source Files\QRM Output\2016') ;

Not applicable
Author

Thanks Tamil.. its working

tamilarasu
Champion
Champion

My pleasure Sowmya. Have a good day.