Importing CSV data for a tracker program relying on an attribute category

Good day,

I recently created a tracker program that relies on an attribute category to define the implementing partner. (Post here).

The problem is that the use of the attribute category is now preventing the import of data in a CSV format. I downloaded some pre-captured events to see what the column configuration should be and the downloaded CSV file has no indication of attribute category (I can see the information in the JSON version).

Looking through the community, I noticed that has seemingly been a limitation for some time and I was wondering whether this has been resolved? If so, any guidance in terms of generating CSV files that can be imported would be greatly appreciated as the use of JSON is just not feasible at this point in time.

Kind regards,

Andre

Hi @ACoetzer1988

You are right, the downloaded CSV is not using the same format used for importing CSV; however, here’s a solution by @nancyesp:

And, yes please let us know if this is resolved! (: Thanks!

Hi @Gassim

Thank you for sharing the information with me. I have worked through it, but I am struggling a little bit as the previous thread referred to Org Units so I am not entirely sure what is relevant and what not.

To the best of my understanding, I can look at the path at the top of an exported JSON file and use that information to determine what the different headings should be in the CSV file. Is that correct? Or am I missing the idea behind the solution?

Furthermore, is there another way to determine the path if my use of JSON information is indeed correct? The JSON information is very detailed and I am not entirely sure what to make of the information in terms of headings etc.

Thank you for helping once again.

Hi @ACoetzer1988,
Actually, I think it’s the opposite. The exported file doesn’t follow the required column order for import. Whatever object type you are trying to import, the CSV file would still have to follow the same order mentioned in the docs for CSV imports. What is the object type that you are trying to import? I think you will have to import every object type separately, too!

“JSON information is very detailed,” so I think you can use parameters to filter out the details that you don’t want. Maybe a screenshot would help. Thank you @ACoetzer1988!

Hi @Gassim

Thanks for the guidance thus far. I have been doing some reading based on your feedback (thus my slow response).

I am trying to import data for a capture program with implementing partners and found the following outline for the CSV file’s column orders.

The problem is that there is seemingly no column for the “attributeCategoryOptions” and I cannot find any information on how to incorporate that into the CSV sheet.

I have downloaded some captured records in CSV and JSON. The downloaded CSV file give no indication of the “attributeCategoryOptions”, but I can change data values in the CSV and upload back to the instance (updated records). The JSON provides all of the relevant background information for the attributeCategoryOptions but I don’t know how to incorporate that into the CSV (in terms of column number allocated to the variable).

CSV

JSON

Is it even possible to do a CSV import of capture program data using attributeCategoryOptions? I saw some posts dating back to 2016 stating that it was not possible, but something that would be considered in future instances.

Thanks,

Andre

Hi @ACoetzer1988,
Hope all is going well! I had to research “attributeCategoryOptions” and it seems like it’s the same as categoryOptionCombo which you can find here https://play.dhis2.org/2.36.4/api/categoryOptionCombos

Just a heads up, I’m sorry to say that it might not always be possible to import using CSV and thus you might eventually have to use JSON / api (or create a feature request in jira.dhis2.org for a possibility to import using CSV). Thanks! (:

I think that the categoryOptionsCombos is auto generated and it’s not something that we create so I wonder if it’s even possible to “import” it (maybe leave that categoryOptionsCombo out!). However, it’s possible to import it when “sending data values” I found this in the developer’s manual (search for the word categoryoptioncombo):

Hope this helps! (: