Created
March 3, 2017 17:17
-
-
Save sidharthkuruvila/365935b8a47f62baaeddb84ea37420ab to your computer and use it in GitHub Desktop.
cat test.csv | sort | python dedup.py
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
import itertools | |
import sys | |
for k, s in itertools.groupby(sys.stdin.readlines(), lambda x: x.split(",")[0]): | |
sys.stdout.write(next(s)) |
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
a | 2 | |
---|---|---|
b | 3 | |
a | 3 | |
c | 3 | |
c | 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment