7 Replies Latest reply: Oct 15, 2013 12:58 PM by Albert Mays RSS

    Loading XML data to Qlikview by using loops.

      Hello everyone,

       

      I need help with loading data from xml to qlikview by using a looping function.  My main objective is to extract data from multiple files within my computer to qlikview, then store it.  Currently, my code is below, but it has not worked.

       

       


      set Root="Y:PGFiles";

      let q = 0;





      FOR EACH file IN FILELIST('$(Root)\*.xml') ;





      let q = q+1;

      let ANALYSIS = "ANALYSIS";

      let table_name="$(Analysis)" & "$(q)";

       

       

       

      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]);



      Concatenate $("ANALYSIS"):

      LOAD

      VARNAME ,

         
      VALUE as AnalysisValue,

         
      %Key_PATIENTLEVELDATA_E1A59225A73AF151

          
      // Key to parent table: DATA_EXPORT/HEADER

      FROM $(FILE) (XmlSimple, Table is [DATA_EXPORT/PATIENTLEVELDATA/ANALYSIS/RESPONSE]);





      Concatenate $("ANALYSIS"):

      LOAD VARNAME,

         
      VALUE as DemographicValues,

         
      %Key_PATIENTLEVELDATA_E1A59225A73AF151 

      FROM $(FILE) (XmlSimple, Table is [DATA_EXPORT/PATIENTLEVELDATA/DEMOGRAPHICS/RESPONSE]);



      Concatenate $("ANALYSIS"):

      LOAD VARNAME,

         
      SENTIMENT as CommentSentiment,

         
      VALUE as CommentValue,

         
      %Key_PATIENTLEVELDATA_E1A59225A73AF151    // Key to parent table: DATA_EXPORT/PATIENTLEVELDATA

      FROM $(FILE) (XmlSimple, Table is [DATA_EXPORT/PATIENTLEVELDATA/COMMENTS/RESPONSE]);