SHARE
TWEET

mdb.py

a guest Apr 13th, 2012 66 Never
  1. #!/usr/bin/env python3.0
  2.  
  3. import codecs
  4.  
  5. filein = 'heads_of_state.txt'
  6. fileout = 'mdb.txt'
  7.  
  8. setHeads = set()
  9. for line in codecs.open(filein, 'r', 'utf-8'):
  10.     setHeads.add(line.strip())
  11. liHeads = sorted(setHeads, key=lambda a: (len(a), a))
  12. liHeads = filter(lambda a: len(a) > 4, liHeads)
  13. codecs.open(fileout, 'w', 'utf-8').write("\n".join(liHeads))
RAW Paste Data
Top