core.py 720 Bytes
Newer Older
Sanjay Krishnan committed
1 2 3 4 5 6 7 8 9 10
'''
The core module sets up the data structures and 
and references for this programming assignment.
'''

import platform
import os
import json

def imdb_title_words():
Krishnan Sanjay committed
11
    f = open('title.csv','r', errors='replace')
Sanjay Krishnan committed
12 13 14 15 16 17 18 19 20 21 22 23 24
    line = f.readline()

    while line != "":
        words = line.strip().split(',')[1].split()

        for w in words:
            yield w

        line = f.readline()

    f.close()

def imdb_years():
Krishnan Sanjay committed
25
    f = open('title.csv','r', errors='replace')
Sanjay Krishnan committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
    line = f.readline()

    while line != "":
        csvsplit = line.strip().split(',')
        year = csvsplit[len(csvsplit) - 8]
        
        if year.strip() != "":
            yield year

        line = f.readline() 
    f.close()