2022-10-26 14:38:19 +02:00
|
|
|
f = open ("books.csv", "r")
|
|
|
|
max = 0
|
|
|
|
f.readline()
|
2022-10-26 18:22:20 +02:00
|
|
|
for t in f:
|
|
|
|
ligne = t.split(",")
|
2022-10-26 14:38:19 +02:00
|
|
|
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()
|
|
|
|
|
|
|
|
|
2022-10-26 18:22:20 +02:00
|
|
|
|