10 Replies Latest reply on Jan 10, 2018 5:57 PM by tyadav RSS
    tyadav Apprentice

    Writing a value stream using the CSVParser extension

    Hi,

     

    I am trying to generate a CSV file with all of the properties of the thing (stored in a valuestream).

     

    I am using the example code for WriteCSV file given in PTC as a service in a thing and a CSV file is being generated with the headers from the DataShape. However, I am not getting the values for the respective properties in the CSV file. The code is as follows and I would like to know what changes are to be made (or a new example)  in order to populate the rows with the corresponding values from the value stream.

     

     

     

    Thanks!

     

     

    Best regards,

    Tushar

     

     

     

     

    var params = {

                infoTableName : "result",

                dataShapeName : "Test4_DataShape"

    };

     

     

    // CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(ds1)

    var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

     

     

    var newRow = new Object();

    newRow.firstfield = "Speed";

    newRow.secondfield = "Distance";

    //infotable1Object.rows[0] = newRow;

    result.AddRow(newRow);

     

     

      var params2 = {

      path: "test3.csv" /* STRING */,

      data: result /* INFOTABLE */,

      fileRepository: "SystemRepository" /* THINGNAME */,

      withHeader: true /* BOOLEAN */

      };

      // no return

      var result = Resources["CSVParserFunctions"].WriteCSVFile(params2);