Skip to content

Instantly share code, notes, and snippets.

@sidharthkuruvila
Created March 3, 2017 17:17
Show Gist options
  • Save sidharthkuruvila/365935b8a47f62baaeddb84ea37420ab to your computer and use it in GitHub Desktop.
Save sidharthkuruvila/365935b8a47f62baaeddb84ea37420ab to your computer and use it in GitHub Desktop.
cat test.csv | sort | python dedup.py
import itertools
import sys
for k, s in itertools.groupby(sys.stdin.readlines(), lambda x: x.split(",")[0]):
sys.stdout.write(next(s))
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