Julia Pais Anal [updated] Access
println("\n--- Country analysis demo ------------------------------------------------\n")
report = analyze_country("France"; gdp_table=sample_gdp) println(report)
data = JSON3.read(String(resp.body))[1] # REST Countries returns an array; we take the first match julia pais anal
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`.
# ---------------------------------------------------------------- # 3️⃣ Core function: fetch + analyse # ---------------------------------------------------------------- """ analyze_country(name_or_code::AbstractString; gdp_table=nothing) sample_gdp = Dict( "FRA" => 41_463
# ---------------------------------------------------------------- # 1️⃣ Data structures # ---------------------------------------------------------------- """ CountryInfo
# ---------------------------------------------------------------- # 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 ) sample_gdp = Dict( "FRA" =>
* `gdp_table` – optional `DictString,Float64` mapping ISO‑3 codes to GDP per‑capita in USD. If supplied, the function also returns an “economic weight” = population × GDP/Capita.