programlibs/Csv/demos/cities.xtl

A small dataset as CSV: read it into a table, take columns by name, summarize them with Statistics, and set a report with Format. The data is the file cities.csv beside this program, built in when the program is compiled (X_eTaL's system macro i_nclude<), so it needs no file access when it runs, in a terminal or in the browser. Run with "just demo Csv cities".

source · imports cs: libs/Csv/src/Csv.xtl libs/Csv/src/Csv.xtlm; sx: libs/Statistics/src/Statistics.xtl; f: libs/Format/src/Format.xtl

data : Char

value · line 12
data ← @ i̲nclude< "cities.csv"
i̲nclude< expands to
("city,country,population,area\nOslo,Norway,709037,454\n\"Washington, D.C.\",USA,678972,177\nLima,Peru,10092000,2672\nPerth,Australia,2192229,6418\nTurin,Italy,848885,130\n")
Used in: t

t : Box Char

value · line 13
t ← ᶜˢr̲ows data

pop : Float

value · line 14
pop ← "population" ᶜˢn̲umbers t

area : Float

value · line 15
area ← "area" ᶜˢn̲umbers t

density : Float

value · line 18
density ← pop ÷ area