Skip to content

Instantly share code, notes, and snippets.

@AlexRezit
Created February 6, 2013 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexRezit/4722511 to your computer and use it in GitHub Desktop.
Save AlexRezit/4722511 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import sys
import string
import re
word_separator = re.compile('(?:,|\n)')
filename = sys.argv[1]
filedata = open(filename).read()
lines = re.compile('\n').split(filedata)
words = word_separator.split(filedata)
for line in lines:
for comp in re.compile(',').split(line):
if not words.count(comp) > 1:
lines.remove(line)
break
print string.join(lines, '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment