2
$\begingroup$

I am using the data which is available in the links below to get data about confirmed cases for COVID-19 in Colombia. I am modeling the cumulative cases with a non linear model and all is fine. This has been made by downloading the data to work locally. I know that there are mechanisms for web development and much what I need I found in this community, except I do not know how to make the graphics update automatically from the data found in the links in a web page.

https://www.datos.gov.co/Salud-y-Protecci-n-Social/Casos-positivos-de-COVID-19-en-Colombia/gt2j-8ykr/data

https://www.datos.gov.co/w/gt2j-8ykr/dneh-mcp2?cur=i2Z4n-Qy94T&from=root

Thanks for your suggestions!

$\endgroup$
4
$\begingroup$

It appears to use Socrata to manage the data. I have no experience with this API, but it appears you can access it using this form of the URL:

https://www.datos.gov.co/Salud-y-Protecci-n-Social/Casos-positivos-de-COVID-19-en-Colombia/gt2j-8ykr

According to the Socrata documentation, you can request this data at a particular $offset and $limit by providing these as parameters in the URL. This is a bit niche, and beyond the scope of Mathematica Stack Exchange, but this will hopefully get you started:

(* fetch 10 records starting from offset 0 *)
request = 
  HTTPRequest["https://www.datos.gov.co/resource/gt2j-8ykr.json",
   <| Method -> "GET", "Query" -> {"$limit" -> 10, "$offset" -> 0}, 
    CharacterEncoding -> "UTF8"|>];
response = URLExecute[request];

We can then query properties of the response JSON by forming an Association:

(* of our 10 records, get the first 5 cities of location *)
Association[#]["ciudad_de_ubicaci_n"] & /@ response[[1 ;; 5]]
(* {"Bogotá D.C.", "Guadalajara de Buga", "Medellín", "Medellín", "Medellín"} *)

If you want the total number of entries in the database (cases) then I reckon you could use the API like this $select=count(id_de_caso):

request = 
  HTTPRequest["https://www.datos.gov.co/resource/gt2j-8ykr.json",
   <| Method -> "GET", 
      "Query" -> {"$select" -> "count(id_de_caso)", "$offset" -> 0}, 
      CharacterEncoding -> "UTF8"|>];
response = URLExecute[request];

numberOfCases = ToExpression@Values[First[response]][[1]]

(* 456689 *)

This matches up exactly with the data for Columbia at https://www.trackcorona.live/map as of 16th August 2020.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you for your response, I really appreciate the elaboration. I will begin to study it. $\endgroup$ – DIEGO R. Aug 16 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.