In Lil, the readcsv[] function takes an optional string specifying a type for each column to decode:
purchases:readcsv[read["purchases.csv"] "sii"]
Summing a column: sum purchases.amount
To create a summary, we need to reduce each group to a single row: select first country sum amount by country from purchases
Discounting: select first country sum amount-discount by country from purchases
Lil doesn't have a "median" primitive. Decks can contain multiple modules, but we happen to know this one is alone. Your path will vary: stats:first import["stats.deck"]
select first country sum amount-discount by country where amount<stats.median[amount]*10 from purchases
Calculating the median within each group is merely a matter of reordering clauses: select first country sum amount-discount where amount<stats.median[amount]*10 by country from purchases
The string to specify the column types is not a terrible idea. Does it have other configuration options, like whether or not to assume the first row is the headers, or specifying the separator character?