Created
February 9, 2023 08:55
-
-
Save outout14/db11c46e72756e5210c3ac3ec8a493ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
with open('liste01.csv', 'r', encoding="latin-1") as f: | |
lecture = csv.reader(f, delimiter=";") | |
data = list(lecture) | |
data = data[1:5] | |
compteur = {} | |
for ligne in data: | |
print(f"ligne : {ligne}") | |
print(f"colonne 3 : {ligne[2]}") | |
# Compter : | |
try: # Essayer si l'index correspondant à la valeur de la troisieme colonne existe dans le compteur, on l'incrémente de 1 | |
compteur[ligne[2]] += 1 | |
except: # Si il existe pas on créait l'index et on l'initialise a 1 | |
compteur[ligne[2]] = 1 | |
# En gros le compteur est un tableau qui contient un compteur par valeur. | |
# Si on a 3 valeurs de "TS40", compteur["TS40"] sera égal à 3. | |
print(compteur) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment