Skip to content

Instantly share code, notes, and snippets.

@FaustinM
Created May 27, 2020 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FaustinM/62325a20a37b92c6d16c640cddc79d13 to your computer and use it in GitHub Desktop.
Save FaustinM/62325a20a37b92c6d16c640cddc79d13 to your computer and use it in GitHub Desktop.
#!/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