Skip to main content
Aug 24, 2017 10:08 AM UTC
Question

How read field of infotable with column name that contain white characters

Hi All,

I'm using a standard services of TW_ML_Helper from Analytics Thingworx.

The service GetScoringResults return a infotable where more fields contain white space in the name.

How can I read the value of these fields?

Many Thanks

BR

Dimitri

2 replies

Sep 6, 2017 7:08 PM UTC

You need to use a for statement to loop over the datashape field names and and then get the value.   Something very similar to this:

var dataShapeFields=myInfotable.dataShape.fields;

for (var x=0; x<myInfotable.length; x++);

var newEntrty=new Object();

for (var fieldName in dataShapeFields) {

            if(dataShapeFields[fieldName].baseType == "INTEGER")

                    newEntry[dataShapeFields[fieldName].name] = parseInt(myInfotable[fieldName]);

                else if(dataShapeFields[fieldName].baseType == "NUMBER")

                    newEntry[dataShapeFields[fieldName].name] = parseFloat(myInfotable[fieldName]);

                else

                    newEntry[dataShapeFields[fieldName].name] = myInfotable[fieldName];

            }

}

Sep 6, 2017 8:49 PM UTC

HI All,

if the name of the field is "Name Of Field" , if you want to read a value of this field you must to use the following code

 

var row=InfoTable.getRow(ii);

var valore=row[“Name Of Field”];

BR

Dimitri