Created
May 27, 2020 08:23
-
-
Save FaustinM/62325a20a37b92c6d16c640cddc79d13 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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import csv | |
tableau=open("/home/project/SNT/elements-data3.csv","r") | |
reader = csv.reader(tableau,delimiter=";") | |
result=[] | |
recherche = input("Que voulez-vous rechercher ? ") | |
for row in reader: | |
if recherche.lower() in row[1].lower(): | |
result.append(row) | |
if result: | |
print("------------- Résultat -------------") | |
print(f"{len(result)} élément(s) ont été trouvé") | |
print("------------------------------------") | |
for row in result: | |
print("Symbole : ", row[0]) | |
print("Nom : ", row[1]) | |
print("Num Atomique : ", row[4]) | |
print("Famille : ", row[-1]) | |
print("Année : ", row[16]) | |
print("------------------------------------") | |
else: | |
print("------------- Résultat -------------") | |
print(f"{len(result)} élément(s) ont été trouvé") | |
print("------------------------------------") | |
print("Je n'ai rien trouvé") | |
# Search | |
# En gros, on prend une input, on liste tout les noms | |
# A chaque fois on check si input dnas nom | |
# Exameple hydro > hydrogene | |
# Quand ça match on ajoute la ligne à un tableau result | |
# inium > Galinium, Actinium, etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment