Search code examples
datasetdecimalpreviewpercentageckan

CKAN automatically converts my data in percentages to decimal in Data Preview


I am working on CKAN and have been loading datasets in it. I have observed that for datasets containing percentages, CKAN automatically converts my values in percentages to decimal in Data Preview. Anyone knows how to prevent this from happening and allow CKAN to display my percentage values as it is?


Solution

  • The issue here is that the data is not locally in CKAN in its DataStore.

    What happens when you have "remote" data (not stored in the DataStore) is that the Data Preview code has to load the data from the remote data file via the Data Proxy app (https://github.com/okfn/dataproxy).

    The Data Proxy app does automated type-guessing to convert from the raw data to the JSON that the Data Preview can use and that type guessing is converting percentages to decimals. There's no way really to customize the Data Proxy behaviour from CKAN on a per dataset basis (and e.g. tell it not to convert percentages to decimals).

    The solution for you really is to store the data from that dataset in the DataStore because then you would be able to control how a given data field/column was stored, in particular you could control the "type" (string, number etc) of that field.

    Hope this helps.