Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

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

Loading xml files from several folders

Hi,

I have a folderstructure something like this c:\Orders\<Year>\<Monthnumber>\<Daynumber>\ and in every Daynumber folder there are several xml files which all have the same fields.
New folders are automatically created when needed (a new Daynumber folder every day, a new Monthnumber folder everey month and a new Year folder every year)

When loading xml files, two tables are generated.

Example:

MessageLine:
LOAD Key_Field,
    fieldname1,
    fieldname2,
    ....
    fieldname n
FROM (XmlSimple, Table is [Messages/Message/MessageLine]);

Messages:
LOAD Key_Field,
     fieldnameA,
     fieldnameB,
     ......
    
FROM (XmlSimple, Table is [Messages]);

This gives me all the xml files located in C:\Orders\2012\12\01\

But how can I load all the xml files from every Daynumber folders (for all years, months and days)?

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Not applicable

Re: Loading xml files from several folders

See here for a script to load files from a directory and its subdirectories.


talk is cheap, supply exceeds demand
2 Replies
Gysbert_Wassenaar
Not applicable

Re: Loading xml files from several folders

See here for a script to load files from a directory and its subdirectories.


talk is cheap, supply exceeds demand
Not applicable

Re: Loading xml files from several folders

Thanks,

made some small modifications, this seems to work for me:

sub ScanFolder(Root)

          for each FileExtension in 'xml'

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

                              MessageLine:

                              Load

                                        '$(FoundFile)'               as [FilenameWithPath],
                                        '$(FileExtension)'           as [Extension],
                                           other fields....   

                                              .....
                        FROM [$(FoundFile)] (XmlSimple, Table is [Messages/Message/MessageLine]);
                                        
  
                           Messages:
        
                             Load
                                   fields....

                             FROM [$(FoundFile)] (XmlSimple, Table is [Messages]);
 
                    next FoundFile

          next FileExtension

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

                    call ScanFolder(SubDirectory)

          next SubDirectory

end sub

Call ScanFolder('C:\Orders') ;