Julia Pais Anal Official
* `name_or_code` can be a common name (“France”), an ISO‑2 code (“FR”), or an ISO‑3 code (“FRA”).
You can extend any of the steps (e.g., add more fields, plug in a different data source, or compute extra statistics). # -------------------------------------------------------------- # Country analysis feature for Julia # -------------------------------------------------------------- using HTTP using JSON3 using DataFrames # optional, only needed if you want tabular output using Statistics # for mean, median, etc. using Printf # for nice formatting julia pais anal
# ---------------------------------------------------------------- # 4️⃣ Example usage # ---------------------------------------------------------------- if abspath(PROGRAM_FILE) == @__FILE__ # run only when this file is executed directly # Example: a tiny GDP table (USD per‑capita). In real life you would # load this from a CSV, an API, or a more complete dataset. sample_gdp = Dict( "FRA" => 41_463.0, "DEU" => 46_215.0, "JPN" => 40_247.0, "BRA" => 7_498.0, "USA" => 69_287.0 ) * `name_or_code` can be a common name (“France”),
# ---------------------------------------------------------------- # 2️⃣ Helper functions # ---------------------------------------------------------------- # Turn a dictionary of languages (e.g. "spa"=>"Spanish") into a vector of strings. languages_from_dict(dict::Dict) = collect(values(dict)) "spa"=>"Spanish") into a vector of strings
data = JSON3.read(String(resp.body))[1] # REST Countries returns an array; we take the first match