Skip to content

Instantly share code, notes, and snippets.

@mikestratton
Created April 13, 2015 23:36
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 mikestratton/9289aa9ca65e5a6e5435 to your computer and use it in GitHub Desktop.
Save mikestratton/9289aa9ca65e5a6e5435 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import re
file=open("HAWAII_GOV_readout_ANSI.txt","r+")
wordcount={}
for word in file.read().split():
#remove alphanumeric characters and underscores
word = re.sub('[^\w]', '', word)
if word not in wordcount:
wordcount[word] = 1
else:
wordcount[word] += 1
for k,v in wordcount.items():
print(k,v)
#print(word,wordcount)
file.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment