示例#1
0
def createTimeTable():

    import Timing
    periods = len(Timing.makePeriods())
    days = Timing.daysOfMonth()
    import pandas as pd
    dataF = pd.DataFrame(index=days,
                         columns=['P%s' % (i + 1) for i in range(periods)])
    dataF = dataF.rename_axis('Days', axis='index')
    dataF = dataF.fillna(theDefaultEmptyChar())
    dataF.to_csv(TIME_TABLE_FILE_NAME)
示例#2
0
def generateTimeTable():
    'class whose timetable is to be generated'

    import math
    import Timing
    timeList = Timing.makePeriods()
    daysOfMonth = Timing.daysOfMonth()

    import pandas as pd
    timeTable = readTimeTable()
    subjects = readBooksFile()

    import random
    random.shuffle(subjects)

    for dayIndex in range(len(daysOfMonth)):
        d = daysOfMonth[dayIndex]
        tempSubjects = list(subjects)
        for p in timeTable.columns:
            if (len(tempSubjects) != 0):
                random.shuffle(tempSubjects)
                temp = tempSubjects.pop()
                if ((timeTable.loc[d, p] == theDefaultEmptyChar())):
                    factor = math.ceil(temp[1] / len(daysOfMonth))
                    markup = "<a target='_blank' href='%s'> %s<br>%d to %d </a>" % (
                        temp[2], temp[0], dayIndex * factor,
                        (dayIndex + 1) * factor)
                    timeTable.loc[d, p] = markup
        else:
            if (len(tempSubjects) != 0):
                print("Not enough slots")

    newColumns = dict()
    for i in range(len(timeList)):
        key = 'P%d' % (i + 1)
        newColumns[key] = timeList[i]
    timeTable = timeTable.rename(columns=newColumns)
    dataFrameToHtmlString(timeTable)