question

Upvotes
Accepted
45 4 3 9

Can you easily convert a DSDataResponse object to a datatable in C#

Can you easily convert a DSDataResponse object to a datatable in C# ?

The DSDataRequest is passing multiple Instrument and DataTypes objects returning to a DSDataResponse.

Thanks,

Fergal

apidatastream-apidsws-api.net
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@fergal.twomey
Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query? If yes please click the 'Accept' text next to the reply. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.
Thanks,
-AHS

1 Answer

· Write an Answer
Upvotes
Accepted
446 2 2 2

Hi @fergal.twomey

There is no simple means of converting from DSDataResponse to a C# DataTable. You would have to walk through the response collection and build the DataTable on the fly.

The ProcessSnapshot method in the GetData example code produces tabulated output on the console. Converting that to a DataTable should be simple enough; simply replace the code constructing a line of tabulated output with code constructing a DataRow object.

For Timeseries requests, especially with multiple instruments in each request, the construction would be more complex. You would want multiple DataTables, one for each instrument, and each row being the data for a specific date. The ProcessTimeSeries method in the GetData example code also produces tabulated data, albeit with the dates represented as columns. You would have to pivot that data to get the dates as rows.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.