xdufacool/score_helper.py
def collect(scores, weights, tasks, output, **kwargs):
    """Collected scores downloaded from AI studio and save to output."""
    assert len(tasks) == len(weights)
    assert len(scores) == len(weights)

    scores_all, students = {}, {}
    fields = [kwargs["sid_baidu"], kwargs["score_baidu"], kwargs["name_baidu"]]
    for xlsfile, task in zip(scores, tasks):
        data = load_xls(xlsfile)
        sid_col, score_col, name_col = find_column_index(data[0], fields)
        score_task = value_dict(data, sid_col, score_col)
        scores_all[task] = score_task
        
        stus = value_dict(data, sid_col, name_col)
        students = merge_students(students, stus)

    weights_dict = {t: w for t, w in zip(tasks, weights)}
    data, errors = merge_scores(scores_all, weights_dict)
    fields = [kwargs["sid_baidu"]] + list(tasks) + ["加权平均分"]
    form = score_dict_to_table(data, fields)
    fmt = output.split(".")[-1]
    if "csv" == fmt:
        write_csv(form, output)
    elif "xls" == fmt:
        write_xls(form, output)
Collected scores downloaded from AI studio and save to output.
Collected scores downloaded from AI studio and save to output.
Collected scores downloaded from AI studio and save to output .
def collect(scores, weights, tasks, output, **kwargs):
    assert len(tasks) == len(weights)
    assert len(scores) == len(weights)
    scores_all, students = {}, {}
    fields = [kwargs["sid_baidu"], kwargs["score_baidu"], kwargs["name_baidu"]]
    for xlsfile, task in zip(scores, tasks):
        data = load_xls(xlsfile)
        sid_col, score_col, name_col = find_column_index(data[0], fields)
        score_task = value_dict(data, sid_col, score_col)
        scores_all[task] = score_task
        stus = value_dict(data, sid_col, name_col)
        students = merge_students(students, stus)
    weights_dict = {t: w for t, w in zip(tasks, weights)}
    data, errors = merge_scores(scores_all, weights_dict)
    fields = [kwargs["sid_baidu"]] + list(tasks) + ["加权平均分"]
    form = score_dict_to_table(data, fields)
    fmt = output.split(".")[-1]
    if "csv" == fmt:
        write_csv(form, output)
    elif "xls" == fmt:
        write_xls(form, output)
def collect ( scores , weights , tasks , output , ** kwargs ) : assert len ( tasks ) == len ( weights ) assert len ( scores ) == len ( weights ) scores_all , students = { } , { } fields = [ kwargs [ "sid_baidu" ] , kwargs [ "score_baidu" ] , kwargs [ "name_baidu" ] ] for xlsfile , task in zip ( scores , tasks ) : data = load_xls ( xlsfile ) sid_col , score_col , name_col = find_column_index ( data [ 0 ] , fields ) score_task = value_dict ( data , sid_col , score_col ) scores_all [ task ] = score_task stus = value_dict ( data , sid_col , name_col ) students = merge_students ( students , stus ) weights_dict = { t : w for t , w in zip ( tasks , weights ) } data , errors = merge_scores ( scores_all , weights_dict ) fields = [ kwargs [ "sid_baidu" ] ] + list ( tasks ) + [ "加权平均分"] form = score_dict_to_table ( data , fields ) fmt = output . split ( "." ) [ - 1 ] if "csv" == fmt : write_csv ( form , output ) elif "xls" == fmt : write_xls ( form , output )
Collected scores downloaded from AI studio and save to output.
Collected scores downloaded from AI studio and save to output .
"""Collected scores downloaded from AI studio and save to output."""
scores
weights
tasks
output