Julia Pais Anal -

report = analyze_country("France"; gdp_table=sample_gdp) println(report)

* `name_or_code` can be a common name (“France”), an ISO‑2 code (“FR”), or an ISO‑3 code (“FRA”).

println("\n--- Country analysis demo ------------------------------------------------\n") julia pais anal

# ---------------------------------------------------------------- # 3️⃣ Core function: fetch + analyse # ---------------------------------------------------------------- """ analyze_country(name_or_code::AbstractString; gdp_table=nothing)

return CountryReport(info, density, gdp_per_capita, econ_weight) end ")") for (_

# 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

# ---- 3️⃣ Compute derived metrics -------------------------------- density = info.area_km2 > 0 ? info.population / info.area_km2 : missing ( name = rpt.info.name

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