Streaming dataValueSets.csv results in the app platform

Hello,

Hope you are having a great day. I’m trying to use the data engine to stream results from the dataValueSets.csv endpoint, any guidance on how to do this (if possible) with the data engine?

Many thanks in advance!
Pete

1 Like

Welcome @plinnegan!

Here this link you find many scenarios

https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-241/data.html

I’m sure you can do it :clap:

Hi Hany!

Thanks for responding, I’ve been using the api’s described in the docs there yes, but my problem is in how to use this with the data engine from the app platform, which the docs don’t have any information on sadly. :pensive_face:

Hi @plinnegan :waving_hand:.

Do you want more examples of how to use useDataEngine, or how to use for accessing dataValueSets, or how to use when accessing a csv resource?

You might want to look at the analytics engine definitions if it’s one of the former cases (analytics/src/api/analytics/Analytics.js at master · dhis2/analytics · GitHub).

If there’s some problem with processing results from csv endpoint, let us know. I think the useDataEngine hook assumes json (app-runtime/services/data/src/engine/DataEngine.ts at master · dhis2/app-runtime · GitHub), but it might work with csv anyway.

1 Like

Thanks Tom!

My specific example is I would like to stream the data from the api/dataValueSets.csv endpoint. Currently if I use useDataEngine I just get a single blob back of all the data, however I would like to instead injest the stream using a ReadableStream. See for example in the MDN web docs.

I’ve been able to for around this by just using fetch, but then there’s all the faff with auth when running in dev mode when you are are using --proxy. And I would like to keep all my requests using the data engine in some way or another if possible. I realise it’s very edge case though as it’s needed because I am processing a lot of data and want to keep the memory usage low in the application.