Created
January 22, 2016 02:16
-
-
Save valericus/ae92ccc25d098ae71210 to your computer and use it in GitHub Desktop.
This file contains 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
def top_10_ip(file_object): | |
result = {} | |
for line in file_object: | |
ip = line.split()[0] | |
if result.setdefault(ip, 1): | |
result[ip] += 1 | |
return sorted(result, key=lambda x: result[x], reverse=True)[:10] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment