Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Silambarasan1306
Creator III
Creator III

How to use loop concept in Script

I have 3 excel files, that is 2700,2701,2702. How can i load these files using loop concept.

Could anyone pls help me.

7 Replies
its_anandrjs

jagan
Luminary Alumni
Luminary Alumni

Hi,

You can load all the files using wildcard characters like below, no need of loops here

Data:

LOAD

*,

FileName() AS ExcelFileName

FROM *.xlsx

-----------------;

Hope this helps you.

Regards,

jagan.

Silambarasan1306
Creator III
Creator III
Author

I'm not getting clear explanation. Could u pls try to explain me in some other way. Beca i have multiple excel files. not excel sheets.

Anonymous
Not applicable

Why not run this script?

I am hoping you r having same fields in all the excel files......

Test:

Load

*

From ExcelFielName27*;   // * is here a wild card char and load all the files starting with '27' into one file, say Test

thepope
Contributor II
Contributor II

Hi,

As   

You can load all the files using wildcard characters like below, no need of loops here

Data:     //This is the name of the table you will create

LOAD   // This lets qlikview know you are loading new data

*,          // The * means load all the fields in the spreadsheet

FileName() AS ExcelFileName   // This statement will let you know which spreadsheet the data came from

FROM *.xlsx // this will load all the spreadsheets (Excel Files) in the folder

If you use the "load table" wizard then everything should be straight forward

reddy-s
Master II
Master II

Hi Silambarasan,

Try something like this:

Set vConcatenate = ;

sub ScanFolder(Root)

          for each FileExtension in 'csv'

                    for each FoundFile in filelist( Root & '\*.' & FileExtension)

                              FileList:

                              $(vConcatenate)

                              LOAD *, '$(FoundFile)' as SourceFile

                              FROM [$(FoundFile)] (txt, codepage is 1252, embedded labels, delimiter is ',', msq, header is 2 lines);

                              Set vConcatenate = Concatenate;

                    next FoundFile

          next FileExtension

          for each SubDirectory in dirlist( Root & '\*' )

                    call ScanFolder(SubDirectory)

          next SubDirectory

end sub

Call ScanFolder('C:\Users\hic\Documents\2012\Work\QV Apps\DoDir') ;

Thanks,

Sangram.