Ejemplo n.º 1
0
def createCourseObject(filePath, tableIndex):
    # 创建文档对象
    doc = Document(filePath)
    # 获取课程所在表格
    try:
        courseTable = doc.tables[tableIndex]  #文档中第index个表格
    except Exception as e:
        print(e)
    try:
        # 创建课程对象
        from course.models import Course
        course = Course()
    except Exception as e:
        print(e)
    course.name = coursenameMange(courseTable.cell(2, 1).text)  #课程名称
    course.courseNumber = courseTable.cell(0, 1).text  #课程编号
    course.totalHours = courseTable.cell(1, 1).text  #总学时
    course.courseCategory = getCourseCategory(courseTable.cell(3,
                                                               1).text)  #课程类别
    course.writer = courseTable.cell(4, 1).text  #执笔人
    course.prerequisiteCourses = coursenameMange(courseTable.cell(
        5, 1).text)  #先修课程
    course.credit = courseTable.cell(0, 3).text  #学分
    course.experimentalHours = courseTable.cell(1, 3).text  #实验/上机学时
    course.englishName = courseTable.cell(2, 3).text  #英文名称
    course.appliedSpecialty = courseTable.cell(3, 3).text  #适用专业
    course.auditor = courseTable.cell(4, 3).text  #审核人
    return course