Skip to main content
1-Visitor
September 20, 2016
Question

How to load data into a grid from file repository which contains an excel file?

  • September 20, 2016
  • 1 reply
  • 9363 views

Hi there...

I'm trying to get the excel file content from file repository and load it into gird.

I have tried a couple of services such as csv parsing and load text. While using csv parsing service, i'm getting the content but not able to load it into the grid.(I checked it in debug option)

I'm a beginner to this platform. It will be very helpful if i get some suggestions.

1 reply

1-Visitor
September 20, 2016

Actually there isn't any service to read XLS files, to read it out-of-the-box with TW, the file should be a CSV file or a simple TXT file.

1-Visitor
September 21, 2016

Hi,

If you had build a service to read the CSV file, you just need that this result returns the Infotable which it's readed from the CSV. If you are reading the CSV file with CSV parser extension ( https://marketplace.thingworx.com/Items/csv-parser ) , you just need to:

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

And set Infotable as Service result type.

Then you can build a mashup that consumes this service and bind the service result to the grid.

16-Pearl
May 3, 2018

Are you wanting to display the time difference between all data entries or just a single difference value between 2 data entries?  

Basically you'll query the data history for the Thing using QueryPropertyHistory or one of the single property queries (i.e. QueryNumberPropertyHistory), then you can reference the result Info Table and find the difference between the timestamp values of the 2 rows that you want.  

Example:

var firstDate = new Date(result.rows[0].timestamp);  //milliseconds

var lastDate = new Date(result.rows[1].timestamp);  //milliseconds

var timeDifference = lastDate - firstDate;  //milliseconds

var resultDateTime = new Date(timeDifference);  //Date object

 

I've read that Thingworx uses Joda datetime format so you have to be careful when using Javascript's Date() class.  I believe it's able to convert the resultDateTime to DateTime without any trouble though.

 

My example digs into the InfoTable structure a bit.  There's a good document about the structure of InfoTables somewhere in the Thingworx document catalog that may help understanding InfoTables if you haven't looked into them much; I think it's called "Getting to Know InfoTables."