Last active
December 25, 2015 09:29
-
-
Save ntlk/6954880 to your computer and use it in GitHub Desktop.
actually unique uniq implemented in python
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
import sys | |
import argparse | |
import collections | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-c', action='store_const', const=True, required=False) | |
args = parser.parse_args() | |
lines = sys.stdin.readlines() | |
counter = collections.Counter(lines) | |
for line in set(lines): | |
if args.c == True: | |
line = str(counter[line]) + " " + line | |
sys.stdout.write(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment