Julia Pais Anal May 2026

You can drop the code into any Julia project (v1.6 or newer) and call analyze_country("France") (or any other ISO‑2/ISO‑3 code or common name) to get a ready‑to‑use CountryReport object. | Step | Action | |------|--------| | 1️⃣ Load data | Sends a GET request to https://restcountries.com/v3.1/name/<country> and parses the JSON response. | | 2️⃣ Build a struct | Packs the most useful fields into a CountryInfo struct (population, area, GDP placeholder, etc.). | | 3️⃣ Compute derived metrics | • Population density (people / km²) • “Economic weight” proxy (population × GDP per‑capita, if you provide a GDP table) | | 4️⃣ Pretty‑print | A short, human‑readable summary that can be printed directly in the REPL or logged. |

# Simple pretty‑printer for the report. function Base.show(io::IO, r::CountryReport) i = r.info @printf io "Country: %s (%s / %s)\n" i.name i.iso2 i.iso3 @printf io "Official name: %s\n" i.official_name @printf io "Capital: %s\n" join(i.capital, ", ") @printf io "Region / Subregion: %s / %s\n" i.region i.subregion @printf io "Population: %'d\n" i.population @printf io "Area: %'.2f km²\n" i.area_km2 @printf io "Population density: %'.2f people/km²\n" r.density @printf io "Languages: %s\n" join(i.languages, ", ") @printf io "Currencies: %s\n" join(i.currencies, ", ") @printf io "Flag: %s\n" i.flag_url if r.gdp_per_capita !== missing @printf io "GDP per capita (USD): $%'.2f\n" r.gdp_per_capita @printf io "Economic weight (pop × GDP/Capita): $%'.2f\n" r.economic_weight else @printf io "GDP data not supplied.\n" end end julia pais anal

# ---- 3️⃣ Compute derived metrics -------------------------------- density = info.area_km2 > 0 ? info.population / info.area_km2 : missing You can drop the code into any Julia project (v1

Runs `analyze_country` on every element of `codes` and returns a DataFrame. """ function batch_analyze(codes::VectorString; gdp_table=nothing) rows = [] for c in codes try rpt = analyze_country(c; gdp_table=gdp_table) push!(rows, ( name = rpt.info.name, iso2 = rpt.info.iso2, iso3 = rpt.info.iso3, pop = rpt.info.population, area_km2 = rpt.info.area_km2, density = rpt.density, gdp_per_cap = rpt.gdp_per_capita, econ_weight = rpt.economic_weight )) catch e @warn "Failed for $c: $e" end end return DataFrame(rows) end | | 3️⃣ Compute derived metrics | •

julia pais anal