question

Upvotes
Accepted
26 2 1 5

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 5.0 MiB each and 10.0 MiB total.

1 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 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea