Created
April 4, 2012 14:33
-
-
Save ryanswanstrom/2301823 to your computer and use it in GitHub Desktop.
This code will open a file and count the words. Note, this is mostly just psuedo-code. It is not complete and has not been tested.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| f=open('/tmp/file.dat') | |
| words = {} | |
| for line in f: | |
| print line | |
| line_words = line.split() // returns an array of words separated by whitespace | |
| for word in line_words: | |
| // get the value | |
| val = words.get(word, false) | |
| if val: | |
| val++; | |
| words[word] = val |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment