cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Filling InfoTable with values doesn´t work

tlichtenberger
1-Visitor

Filling InfoTable with values doesn´t work

Hello! I am currently working on Project in Thingworx: My Goal is to visualize data I get from a csv file in two line Charts.

For that, I created a Mashup with a big TextBox, in which i copypaste the csv data in runtime. In addition, i have an grid widget and two linechart widgets.

First of all, after pasting the csv data into the TextBox, a Service is called which parses the data and fills the infotable. The Service's Output is a infotable and the Input Parameter is a string. By now, it Looks like the infotable is filled with empty values so i am kind of confused right now...

My service looks like this:

var txt = CSVinput;
var i = 0;

//var valArray = txt.replace("\n"," ");
var valArray = txt.split(" ");

var params = {
infoTableName : "InfoTable", 
dataShapeName : "LogDataShape"
};
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

var cnt = 0;
while (i < valArray.length-1){
    var row = new Object();
    if(cnt == 0){
  row.DateTime = valArray + " " + valArray[i+1];
        cnt = 1;
    }
else if(cnt == 1){
        row.Temperature = valArray;
        cnt = 2;
    }
    else if(cnt == 2){
        row.Press_601_mbar = valArray;
        cnt = 3;
    }
    else if(cnt == 3){
        row.Press_651_mbar = valArray;
        cnt = 0;
        result.AddRow(row);
    }
i++;
}

the Input string looks like this: in the TextBox, there is exactly one space between each value and I asume a "\n"-endline at the end of the last value.

   

DateTimePress_601_mbarPress_651_mbarTemp_518a_°C
02.03.201723:40:15-93-33235.4
02.03.201723:40:16-95-33335.4
02.03.201723:40:17-97-33435.4
02.03.201723:40:18-99-33335.4
02.03.201723:40:19-101-33335.4
02.03.201723:40:20-102-33635.4
02.03.201723:40:21-101-33835.4
02.03.201723:40:22-95-34335.4
02.03.201723:40:23-88-34635.4
02.03.201723:40:24-85-35335.4
02.03.201723:40:25-83-35635.3
02.03.201723:40:26-85-35835.4
02.03.201723:40:27-87-35635.4
02.03.201723:40:28-88-35635.4

I would really really appreciate any kind of advice or help you can give me!!

Thank you so much in advance!

2 REPLIES 2

Hello,

You are doing your AddRow only for one case:
...
else if(cnt == 3)
...

I don't understand very well your service but you can add the snippet Logger to see what your service is doing.

However, it would not be easier to use an csv parser and directly store your data in to an infotable?



Best regards,

Ana Duarte

posipova
20-Turquoise
(To:aduarte)

Hi,

To add to what Ana has already mentioned, here is the link to download the csv parser extension: https://marketplace.thingworx.com/Items/csv-parser

Announcements


Top Tags