In [1]:
ls


gettysburg_address.txt  table.txt               table_to_dict.ipynb

In [9]:
table = {'ra':[],'dec':[],'name':[]}
for line in file('table.txt'):
    line = line.strip('\n')
    line = line.split(',')
    if line[0] == 'ra':
        continue
    else:
        table['ra'].append(line[0])
        table['dec'].append(line[1])
        table['name'].append(line[2])

In [54]:
linecount = 0
wordcount = 0
a,e,i,o,u = 0,0,0,0,0
all_words = []
for line in file('gettysburg_address.txt'):
    line=line.strip("\n")
    if '--' in line:
        line_2 = line.split('--')
        line = ' '.join(line_2)
    line = line.split()
    linecount += 1
    wordcount += len(line)
    for k in range(len(line)):
        line[k] = line[k].lower()
        a += line[k].count('a')
        e += line[k].count('e')
        i += line[k].count('i')
        o += line[k].count('o')
        u += line[k].count('u')
        all_words.append(line[k].strip(',').strip('.'))
    
all_words.sort()
only_words = []
for k in all_words:
    if k in only_words:
        continue
    else:
        only_words.append(k)
print("Mr. Lincoln said {} words in {} lines".format(wordcount, linecount))
print("He used lots of vowels: \n {} a's, {} e's, {} i's, {} o's, {} u's".format(a,e,i,o,u))


Mr. Lincoln said 267 words in 23 lines
He used lots of vowels: 
 102 a's, 165 e's, 68 i's, 93 o's, 21 u's

In [55]:
print only_words


['a', 'above', 'add', 'advanced', 'ago', 'all', 'altogether', 'and', 'any', 'are', 'as', 'battlefield', 'be', 'before', 'birth', 'brave', 'brought', 'but', 'by', 'can', 'cannot', 'cause', 'civil', 'come', 'conceived', 'consecrate', 'consecrated', 'continent', 'created', 'dead', 'dedicate', 'dedicated', 'detract', 'devotion', 'did', 'died', 'do', 'earth', 'endure', 'engaged', 'equal', 'far', 'fathers', 'field', 'final', 'fitting', 'for', 'forget', 'forth', 'fought', 'four', 'freedom', 'from', 'full', 'gave', 'god', 'government', 'great', 'ground', 'hallow', 'have', 'here', 'highly', 'honored', 'in', 'increased', 'is', 'it', 'larger', 'last', 'liberty', 'little', 'live', 'lives', 'living', 'long', 'measure', 'men', 'met', 'might', 'nation', 'never', 'new', 'nobly', 'nor', 'not', 'note', 'now', 'of', 'on', 'or', 'our', 'people', 'perish', 'poor', 'portion', 'power', 'proper', 'proposition', 'rather', 'remaining', 'remember', 'resolve', 'resting-place', 'say', 'score', 'sense', 'seven', 'shall', 'should', 'so', 'struggled', 'take', 'task', 'testing', 'that', 'the', 'their', 'these', 'they', 'this', 'those', 'thus', 'to', 'under', 'unfinished', 'us', 'vain', 'war', 'we', 'what', 'whether', 'which', 'who', 'will', 'work', 'world', 'years']

In [56]:
out = file('getty_words.txt', 'w')
for w in only_words:
    print >> out, w
out.close()

In [ ]: