Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help needed to write a for loop

Hi All,

Can anyone please let me know how to write a for loop statement for loading data several xml files?This XML files are located in a particular folder.

Instead of loading one by one felt it would be better to load them at one go.

Any help or guidelines  in this regard is highly appreciated.

3 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     This is the sample script to load the files from a folder.

// list all QV related files on disk

SUB DoDir (Root)

FOR Each Ext in 'qvw', 'qva', 'qvo', 'qvs'

FOR Each File in filelist (Root&' \*.' &Ext)

LOAD

'$(File)' as Name,

FileSize( '$(File)' ) as Size,

FileTime( '$(File)' ) as FileTime

autogenerate 1;

NEXT File

NEXT Ext

FOR Each Dir in dirlist (Root&' \*' )

call DoDir (Dir)

NEXT Dir

     ENDSUB

     CALL DoDir ('C:')

 

     I am not giving you proper solution, cause i want you to try by your own logic.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Hi kaushik,

I believe that the example you shared is very good one. I learned new things with it.

Regards,

Vasim

Not applicable
Author

Hi,

Two examples I have tested with Excel files:

Example 1:

 

for each file in FileList('*.xlsx')
Temp_Table1:
load A as ID2,
B as Number2

FROM $(file)

(ooxml, no labels, table is Feuil1);
next

Example 2 even simpler:

 

Temp_Table1:
load A as ID2,
B as Number2

FROM *.xlsx
(
ooxml, no labels, table is Feuil1);

Fabrice