Skip to content

Instantly share code, notes, and snippets.

@liunian
Created April 10, 2012 09:12
Show Gist options
  • Save liunian/2349630 to your computer and use it in GitHub Desktop.
Save liunian/2349630 to your computer and use it in GitHub Desktop.
filter
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import re
def filter(filePath):
f = open(filePath)
content = f.read()
#print content
f.close()
arr = content.split()
#print arr
pattern = ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z')
res = [i for i in arr if i.startswith(pattern)]
#print res
print '\n'.join(res)
if __name__ == '__main__':
if len(sys.argv) != 2:
raise Exception('need to give the file path')
else:
filter(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment