Ejemplo n.º 1
0
def print_results(l_competitors):
    print("Prénom",end="\t")
    print("Nom",end="\t")
    print("Sexe",end="\t")
    print("Num.",end="\t")
    print("Performance")
    l_temp = l_competitors
    while not list1.is_empty(l_temp):
        l_tete = list1.head(l_temp)
        performance = ()
        if len(get_firstname(l_tete)) <= 7 :
            print(get_firstname(l_tete),end="\t")
            print(get_lastname(l_tete),end="\t")
            print(get_sex(l_tete),end="\t")
            print(get_bibnum(l_tete),end="\t")
        else :
            print(get_firstname(l_tete),end=" ") 
            print(get_lastname(l_tete),end=" ")
            print(get_sex(l_tete),end="\t")
            print(get_bibnum(l_tete),end=" ")
        if get_performance(l_tete) == None :
            print()
        else :
            performance = get_performance(l_tete)
            if len(str(get_hours(performance))) == 1 :
                print("0" + str(get_hours(performance)),end=":")
            elif len(str(get_hours(performance))) == 2 :
                print(str(get_hours(performance)),end=":")
            print(get_minutes(performance),end=":")
            print(get_secondes(performance))

        l_temp = list1.tail(l_temp)
Ejemplo n.º 2
0
def read_performances(filename):
    assert (".csv" in filename), 'Le fichier doit être un fichier csv !'
    clef = list1.empty_list()
    cle = []
    stream = open(filename, "r")
    phrase = stream.readline()
    phrase = stream.readline()
    while phrase != '':
        cle = phrase.split(';')
        temp = cle[3].replace('\n', '')
        quadra = (cle[0], create(int(cle[1]), int(cle[2]), int(temp)))
        if list1.is_empty(clef):
            clef = list1.cons(quadra, clef)
        else:
            clef = list1.cons(quadra, clef)
        phrase = stream.readline()
    clef = list1.reverse(clef)
    return clef
Ejemplo n.º 3
0
def read_competitors(filename):
    assert(".csv" in filename),'Le fichier doit être un fichier csv !'
    clef = list1.empty_list()
    d = {}
    cle = []
    stream = open(filename,"r")
    phrase = stream.readline()
    phrase = stream.readline()
    cpt = 1
    while phrase != '' :
        cle = phrase.split(';')
        d = create (cle[0], cle[1], cle[2], cpt)
        if list1.is_empty(clef) :
            clef = list1.cons(d,clef)
        else :
            clef = list1.cons(d,clef)
        phrase = stream.readline()
        cpt = cpt + 1
    clef = list1.reverse(clef)
    return clef
Ejemplo n.º 4
0
def set_performances(l_competitors, l_performances):
    l_temp = l_competitors
    l_competitor_with_performances = list1.empty_list()

    while not list1.is_empty(l_performances):

        if get_bibnum(list1.head(l_temp)) == int(
                list1.head(l_performances)[0]):
            #Vérifie le num du candidat avec le numéro de la performance
            l_competitor_with_performances = list1.cons(
                list1.head(l_temp), l_competitor_with_performances)
            set_perf(list1.head(l_competitor_with_performances),
                     list1.head(l_performances)[1])
            l_performances = list1.tail(l_performances)
        else:
            l_competitor_with_performances = list1.cons(
                list1.head(l_temp), l_competitor_with_performances)
        l_temp = list1.tail(l_temp)

    l_competitors = l_competitor_with_performances
    l_competitors = list1.reverse(l_competitors)
Ejemplo n.º 5
0
def save_results(l_competitors,filename):
    stream = open(filename + ".csv","w+")
    l_temp = l_competitors
    stream.write("Prénom;Nom;Sexe;Num_dossard;Performance\n")
    while not list1.is_empty(l_temp) :
        l_tete = list1.head(l_temp)
        stream.write(str(get_firstname(l_tete)) + ";")
        stream.write(str(get_lastname(l_tete)) + ";")
        stream.write(str(get_sex(l_tete)) + ";")
        stream.write(str(get_bibnum(l_tete)) + ";")
        if get_performance(l_tete) == None:
            stream.write("\n")
        else :
            performance = get_performance(l_tete)
            if len(str(get_hours(performance))) == 1 :
                stream.write("0" + str(get_hours(performance)) +  ":")
            elif len(str(get_hours(performance))) == 2 :
                stream.write(str(get_hours(performance)) +  ":")
            stream.write(str(get_minutes(performance)) + ":")
            stream.write(str(get_secondes(performance)) + "\n")
        l_temp = list1.tail(l_temp)
    stream.close()