Exporting data with special characters / accents

Hi community,

I routinely export lists of metadata objects (e.g., data elements, orgunits) with the API. I used to be able to export an XLS file via the API, and I chose XLS because it would include special characters / accents. For example, the API would look like https://[url]/api/organisationUnits.xls.

However, that doesn’t work since we upgraded to 2.36 a while ago. Downloading CSV (API call looks like https://[url]/api/organisationUnits.csv) exports the metadata differently (for example, what should be “ç” returns as “ç”).

What workarounds are there? Is it still possible to export XLS files, but perhaps the API call changed?

Best,
Luigi

1 Like

Hi @lnunez . I think you could achieve what you want with a GIST call (Metadata Gist - DHIS2 Documentation) for example, this call DHIS 2 Demo - Sierra Leone returns a CSV with those special characters.
image

Thank you! I can’t confirm if this works for accents / special characters since the list in this server doesn’t seem to have any. However, it seems to only work for 2.39 and 2.40. I get this error when trying for 2.38 and below.

1 Like

Hi @lnunez

Thank you for the info. If the same exact steps work in 2.39 and 2.40 but not 2.38, it is possible that a bug got fixed in later versions but not in 2.38, so would you like to create (using your Jira account) a Jira bug ticket with the steps to reproduce? Projects - Jira

Thanks!

Sounds good - I’ve created a Jira ticket here ([DHIS2-15784] - Jira).

FYI - The accents download just fine when using the Excel “Get Data” API call.

So we’ve found our solution (using the Excel feature). :slight_smile:

Luigi

1 Like

We’ve closed the original JIRA ticket ([DHIS2-15784] - Jira) which evolved over time: it showed different characters in Excel importing CSV. After some discussions, Luigi came up with a workaround that I’m posting here for anyone also facing this:

It seems like it’s not as issue with format, it’s more of an issue of encoding. The default encoding of Excel is ANSII, not UTF-8. Accents appear correctly for UTF-8. One solution is to open Excel > click on Data > click Get Data > click From File > click From Text/CSV. After choosing the CSV file that exports from DHIS2 (which will have the corrupted text), the Excel import wizard appears, and then you can click UTF-8 and then click load.

Some resources that were helpful:

Troubleshooting Accented Character Display in CSV Reports | Troubleshooting | Guides & Tutorials

How to change Excel character set?

How to set character encoding when opening a CSV file in Excel?

1 Like