from basic import Basic
import optparse
import subprocess
import csv
import random

ALGORITHMS = ['basic', 'chris', 'creative']
FEATURE_LIST = ['sunet', 't1', 'e1', 't2', 'e2', 't3', 'e3']
TIME_VARS = ['t1', 't2', 't3']
GRADE_VARS = ['g1', 'g2', 'g3']
ENJOY_VARS = ['e1', 'e2', 'e3']
ASSN_IDS = ['1', '2', '3']

def run():
    print 'hello world'
    students = getStudents()
    gradeDict = getFeatureDict('grades.csv')
    evalDict = getFeatureDict('evalData.csv')
    data = []
    for sunetId in students:
        gradeData = gradeDict[sunetId]
        evalData = evalDict[sunetId]
        features = [sunetId] + gradeData + evalData
        data.append(features)
    writer = csv.writer(open('data.csv', 'w'))
    for row in data:
        writer.writerow(row)

def getFeatureDict(fileName):
    featureDict = {}
    csvReader = csv.reader(open(fileName, 'rU'))
    for row in csvReader:
        sunetId = row[0]
        features = row[1:]
        featureDict[sunetId] = features
    return featureDict

def getStudents():
    csvReader = csv.reader(open('evalData.csv', 'rU'))
    evalStudents = []
    for row in csvReader:
        sunetId = row[0]
        evalStudents.append(sunetId)
    csvReader = csv.reader(open('grades.csv', 'rU'))
    students = []
    for row in csvReader:
        sunetId = row[0]
        if sunetId in evalStudents:
            students.append(sunetId)
    students.sort()
    return students
    


if __name__ == '__main__':
    run()
