Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load Multiple XML Files

I have a load script that loads an XML file into various tables. Since I plan to have a repository of XML files how do I write the script so that it loads all of them the same way?

I tried something like this but it only seems to load the 1st XML file it finds.

FROM C:\QlickView\Dashboard\*.xml (XmlSimple, Table is [DATA_EXPORT/PATIENTLEVELDATA]);

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

try with the following:

- before loop entry define Analysis variable: set Analysis="Analysis";

- in the loop:   let q=q+1;

                     let table_name='$(Analysis)' & '$(q)';  // now you can use table_name value as the name of table by setting $(table_name😞 ...

regards

View solution in original post

4 Replies
Not applicable
Author

Hi,

try with the following loop in your script:

// Root variable holds path with xml files

set Root="D:\qlikviewProjects\archive";

FOR each FILE in filelist (Root&'\*.xml')

// create table(s) according to your xml structure, instead table creation below.

table:

LOAD

    number,

    datum,

    FileName(FILE) as key

FROM $(FILE)(XmlSimple, Table is

);

NEXT FILE

regards

Not applicable
Author

I have been able to create a loop, like you suggest, which is helpful.  

The problem I think is that I need to create new table names for each different XML file. I tried to use a variable for the table names where the name is incremented. I guess it shouldn't be a surprise that QlikView doesn't like varibales in place of a table name.

Is there a way to use one load with multiple files? I think that would do the trick if possible.


set Root="C:\QlickView\Dashboard";
let q=0;

FOR each FILE in filelist (Root&'\*.xml')

let q=$(q)+1;
let Analysis="Analysis"+$(q);

PATIENTLEVELDATA:
LOAD SURVEY_ID,
    CLIENT_ID,
    SERVICE,
    RECDATE,
    DISDATE,
    %Key_PATIENTLEVELDATA_E1A59225A73AF151    // Key for this table: DATA_EXPORT/PATIENTLEVELDATA
FROM $(FILE) (XmlSimple, Table is [DATA_EXPORT/PATIENTLEVELDATA]);

$(ANALYSIS):
LOAD SERVICE,
    VARNAME,
    QUESTION_TEXT,
    %Key_HEADER_8B8B72D6FCC98357    // Key to parent table: DATA_EXPORT/HEADER
FROM $(FILE) (XmlSimple, Table is [DATA_EXPORT/HEADER/QUESTION_MAP/QUESTION]);

Join ($(ANALYSIS))
LOAD VARNAME,
'ANALYSIS' As CommentType,
    VALUE,
    %Key_PATIENTLEVELDATA_E1A59225A73AF151    // Key to parent table: DATA_EXPORT/PATIENTLEVELDATA
FROM $(FILE) (XmlSimple, Table is [DATA_EXPORT/PATIENTLEVELDATA/ANALYSIS/RESPONSE]);

NEXT FILE

Not applicable
Author

Hi,

try with the following:

- before loop entry define Analysis variable: set Analysis="Analysis";

- in the loop:   let q=q+1;

                     let table_name='$(Analysis)' & '$(q)';  // now you can use table_name value as the name of table by setting $(table_name😞 ...

regards

Not applicable
Author

Thanks. I was able to simplify with:

let Analysis='Analysis'&'$(q)';