Just for fun. Speed testing awk vs Java. awk -F';' '{ station = $1 temperature = $2 sum[station] += temperature count[station]++ if (temperature max[station] || count[station] == 1) { max[station] = temperature } } END { for (s in sum) { mean = sum[s] / count[s] printf "{%s=%.1f/%.1f/%.1f", s, min[s], mean, max[s] printf (s == PROCINFO["sorted_in"][length(PROCINFO["sorted_in"])] ? "}\n" : ", ") } }' measurement.txt
time clickhouse local -q "SELECT concat('{', arrayStringConcat(groupArray(v), ', '), '}')
FROM
(
SELECT concat(station, '=', min(t), '/', max(t), '/', avg(t)) AS v
FROM file('measurements.txt', 'CSV', 'station String, t Float32')
GROUP BY station
ORDER BY station ASC
)
SETTINGS format_csv_delimiter = ';', max_threads = 8" >/dev/null
real 0m15.201s
user 2m16.124s
sys 0m2.351
Most of the time is spent parsing the file