3 Replies Latest reply on Mar 25, 2016 8:20 AM by jeffm RSS
    jeffm Newbie

    CSV Parser Help

    So, I am running 6.0 and am trying to parse a CSV file.  I have downloaded the CSV Parser Extension and have boiled down the code to the bare minimum and haven't been able to get it to work. 

     

    In fact, I have a very simple test and my results are the same as when I use the GetCSVFile Method.  Here below I am using a very simple example and the result is that I only get the very first column and not the second column. I am certain I am doing something wrong but I haven't been able to locate the documentation for the extension.  I have looked through the forum and found links but they are dead links.  

     

    Can someone help with getting the Description column populated?

     

    Thanks in advance

     

     

    var params = {

      columnMappings: "Tagname; Description;" /* STRING */,

      hasHeader: "false" /* BOOLEAN */,

      longitudeField: undefined /* NUMBER */,

      dateFormat: undefined /* STRING */,

      latitudeField: undefined /* NUMBER */,

      fieldDelimiter: undefined /* STRING */,

      stringDelimiter: undefined /* STRING */,

      content: '"XV101,Valve Input"' /* STRING */,

      dataShape: "PES_Tags" /* DATASHAPENAME */

    };

     

     

    // result: INFOTABLE

    var result = Resources["CSVParserFunctions"].ParseCSVFile(params);

      • Re: CSV Parser Help
        carlesc Ninja

        Few things that may cause it:

         

        • ColumnMappings
          • Remove spaces between columns ( you have a space after the ";" )
          • Remove the last ";"
        • hasHeader
          • change "true" for true
        • FieldDelimiter
          • ","
        • StringDelimiter
          • "\""
        • content
          • I've never parsed a string content, I parse csv files from file repositories
          • But on your case, you are opening and closing a " on your content, you should not, at least for all the row, you can for every String column
          • When you parse CSV files you need a blank line at the end, maybe it's the case with content, then you will need to add at the end \n
        • dataShape, it should exist.
        • Re: CSV Parser Help
          anna Creator

          Hi Jeff,

          Here is an example per the test data you provided and it works on my Thingworx 7.0.0-b479:

          var params = {

           

              columnMappings: "Tagname;Description" /* STRING */,

              hasHeader: "false" /* BOOLEAN */,

              longitudeField: undefined /* NUMBER */,

              dateFormat: undefined /* STRING */,

              latitudeField: undefined /* NUMBER */,

              fieldDelimiter: "," /* STRING */,

              stringDelimiter: "\"" /* STRING */,

              content: "XV101,Valve Input\n" /* STRING */,

              dataShape: "PES_Tags" /* DATASHAPENAME */

          };

          // result: INFOTABLE

          var result = Resources["CSVParserFunctions"].ParseCSVFile(params);

           

          Hope this helps,

           

          Thanks,

           

          Br,

          Anna

          • Re: CSV Parser Help
            jeffm Newbie

            Thanks both of you!!!! My issue was the space between the columnMappings... I appreciate it.