Created
July 20, 2012 18:56
-
-
Save xavivars/3152572 to your computer and use it in GitHub Desktop.
Pipes stdin to stdout removing the words that appear in a given file
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
#!/usr/bin/python | |
import sys | |
# comprovem el parametre | |
if len(sys.argv)<2: | |
print >> sys.stderr, "ERROR: Cal utilitzar un fitxer." | |
# carreguem el diccionari correcte en memoria | |
dicc = {} | |
f = open(sys.argv[1], 'r') | |
for line in f.readlines(): | |
dicc[line.strip()]=1 | |
# llegim i comprovem l'entrada estandar | |
for linea in sys.stdin: | |
if not dicc.has_key(linea.strip()): | |
print linea; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment