f = open ("books.csv", "r") max = 0 f.readline() for row in f: ligne = row.split(",") if int(ligne[0]) > max: max = int(ligne[0]) print("la valeur max est ", max) f.close() f = open("books.csv", "a") titre = input("Un titre: ") auteur = input("Un auteur: ") annee = input("Une année: ") enregistrement = str(max+1) + ", " + titre + ", " + auteur + ", " + annee + "\n" f.write(enregistrement) f.close()