Skip to content

Instantly share code, notes, and snippets.

@amundo
Created January 28, 2010 03:37
Show Gist options
  • Save amundo/288417 to your computer and use it in GitHub Desktop.
Save amundo/288417 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import codecs
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
content = open(sys.argv[1],'rU').read().decode('utf-8')
letters = list(content)
letterfq = {}
for letter in letters:
if letter in letterfq: letterfq[letter] += 1
else: letterfq[letter] = 1
byfq = sorted([(v,k) for k,v in letterfq.items()])
for fq, letter in byfq:
print letter, fq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment