Skip to content

Instantly share code, notes, and snippets.

@bsdlp
Created January 21, 2015 05:35
Show Gist options
  • Select an option

  • Save bsdlp/3c11b5ddba113d59cbf4 to your computer and use it in GitHub Desktop.

Select an option

Save bsdlp/3c11b5ddba113d59cbf4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from itertools import tee
def pairwise(iterable):
"""
http://stackoverflow.com/a/11359174
"""
a, b = tee(iterable)
next(b, None)
return zip(a, b)
with open('top-5K-cleaned.csv', 'w') as fw:
with open('top-5K.csv','r') as fr:
for line, next_line in pairwise(fr):
if line != next_line:
fw.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment