Skip to main content
5-Regular Member
June 7, 2018
Solved

Export to csv through service

  • June 7, 2018
  • 3 replies
  • 5660 views

I have a Thing and valuestream associated to that. Have made properties of that thing logged and persistent so that I can use valuestream for time series. I'm able to get the same in a mashup.

 

If I wanted to write a service which will perform the same function as an export widget in a mashup, I would be able to invoke service every x mins to export the property history to csv

 

Thanks in advance

Best answer by mnarang

Or else you can try using the service "WriteCSVFile" from available snippet .It is like this -

var params = {
 path: undefined /* STRING */,
 data: undefined /* INFOTABLE */,
 fileRepository: undefined /* THINGNAME */,
 withHeader: undefined /* BOOLEAN */
};

// no return
Resources["CSVParserFunctions"].WriteCSVFile(params);

 

It takes data as an infotable which will be coming from the "QueryPropertyHistory" so you can pass that infotable to this service and write this to CSV in repository .

3 replies

5-Regular Member
June 7, 2018

Hello, I think you could use the service in Data Export Extension, the entity it includes have service to help infotable exported as CSV file.

mnarang5-Regular MemberAnswer
5-Regular Member
June 7, 2018

Or else you can try using the service "WriteCSVFile" from available snippet .It is like this -

var params = {
 path: undefined /* STRING */,
 data: undefined /* INFOTABLE */,
 fileRepository: undefined /* THINGNAME */,
 withHeader: undefined /* BOOLEAN */
};

// no return
Resources["CSVParserFunctions"].WriteCSVFile(params);

 

It takes data as an infotable which will be coming from the "QueryPropertyHistory" so you can pass that infotable to this service and write this to CSV in repository .

asekar5-Regular MemberAuthor
5-Regular Member
June 7, 2018

Thank you. This worked

 

Arvind