Panda python

Fermé
Gaarou - 3 mars 2021 à 21:22
Whismeril Messages postés 19028 Date d'inscription mardi 11 mars 2003 Statut Non membre Dernière intervention 24 avril 2024 - 3 mars 2021 à 21:36
Bonjour,
Je dois actuellement créer un programme qui utilise un fichier csv. pour récupérer des informations. Jusqu'ici tout va bien. J'arrive à enregistrer mes informations, mais cela créé un nouveau fichier csv. Pouvez vous m'aider ?

from pandas import DataFrame
import pandas as pd

df = pd.read_csv('user_info.csv', delimiter=';')
b = df['email']
c = df['password']

nombre_element = len(b)

new_mail = input("Rentrez votre adresse email: ")
new_mdp = input("Rentre votr mot de passe: ")

a = 0
for csv_email in df['email'] :
if str(csv_email).strip() == str(new_mail) :
print("Votre adresse mail fait déja partie des données")
a = 1

if a == 0:
df.loc[55] = [54, new_mail, new_mdp]
print("Vous venez de créer votr compte")

df.to_csv("user_info.csv",sep=";",index=False)

print(df)

Bonne journée


Configuration: Windows / Opera 73.0.3856.400
A voir également:

1 réponse

Whismeril Messages postés 19028 Date d'inscription mardi 11 mars 2003 Statut Non membre Dernière intervention 24 avril 2024 931
3 mars 2021 à 21:36
Bonsoir
Il y a un truc primordial en python : l’indentation

En postant sur le site sans utiliser l’outil approprié, le site ne la conserve pas.
Donc impossible de t’aider.

Pour reposter correctement ton code, voir ici https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code
0