Skip to content

Instantly share code, notes, and snippets.

@daGrevis
Created May 8, 2012 19:11
Show Gist options
  • Select an option

  • Save daGrevis/2638567 to your computer and use it in GitHub Desktop.

Select an option

Save daGrevis/2638567 to your computer and use it in GitHub Desktop.
Counts words in the file
import sys, re
if len(sys.argv) == 1:
exit()
with open(sys.argv[1]) as f:
content = f.read()
chunks = re.findall(r'\w+', content)
print('Count:', len(chunks))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment