Skip to content

Instantly share code, notes, and snippets.

@shanginn
Created February 18, 2018 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanginn/305d859d0c2b76e2b0d30a79c7164b90 to your computer and use it in GitHub Desktop.
Save shanginn/305d859d0c2b76e2b0d30a79c7164b90 to your computer and use it in GitHub Desktop.
Yandex SHKIB task 5. # Usage: ./task.awk shkib.csv > result.txt
#!/usr/bin/gawk -f
BEGIN {
FS = ","
PROCINFO["sorted_in"] = "@val_num_desc"
}
{
if ($2 != "") {
most_requests[$2]++
most_out_bytes[$2] += $9
}
}
END {
print "# Поиск 5ти пользователей, сгенерировавших наибольшее количество запросов"
for (i in most_requests) {
print i
if (++n % 5 == 0) break
}
print "# Поиск 5ти пользователей, отправивших наибольшее количество данных"
for (i in most_out_bytes) {
print i
if (++n % 5 == 0) break
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment