Created
February 18, 2018 13:41
-
-
Save shanginn/305d859d0c2b76e2b0d30a79c7164b90 to your computer and use it in GitHub Desktop.
Yandex SHKIB task 5. # Usage: ./task.awk shkib.csv > result.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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