Julia Pais Anal Verified Access
# Turn a dictionary of currencies (e.g. "USD"=>"name"=>"United States dollar","symbol"=>"$") into a vector of strings. function currencies_from_dict(dict::Dict) return [string(v["name"], " (", get(v, "symbol", "?"), ")") for (_, v) in dict] end
if resp.status != 200 error("Could not fetch data for \"$(name_or_code)\" (HTTP $(resp.status)).") end julia pais anal
A lightweight container for the most relevant pieces of information about a country. """ struct CountryInfo name::String # common name official_name::String # official name iso2::String # ISO‑3166‑1 alpha‑2 code iso3::String # ISO‑3166‑1 alpha‑3 code population::Int64 area_km2::Float64 capital::VectorString region::String subregion::String languages::VectorString currencies::VectorString flag_url::String end # Turn a dictionary of currencies (e
Fetches basic data for the given country from the REST Countries API, computes population density, and (optionally) merges a GDP‑per‑capita value from a user‑provided `gdp_table`. using Printf # for nice formatting
report = analyze_country("France"; gdp_table=sample_gdp) println(report)
""" CountryReport
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