-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathemail_zip_OT.py
More file actions
28 lines (23 loc) · 968 Bytes
/
email_zip_OT.py
File metadata and controls
28 lines (23 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#creer une liste contacts vide
#ouvrir le fichier email.txt en lecture
#lire la premiere ligne en applicant strip et split
#vous avez ainsi une liste contenant les headers
#lire les lignes suivantes en applicant la fonction zip ( header, line)
#faire un append dans votre liste contacts du resultat de la fonction zip
#afficher le resultat au format
#email: <value> -- lastname , firstname
#utiliser l'outil python console pour mettre au point votre structure de donnees
with open("email.txt","r") as mail:
LContacts = list()
LContactsL = list()
list = mail.readlines()
header = list[0].rstrip().split(",")
print(header)
for l in list:
if "first" not in l:
LContacts.append(zip(header,l.rstrip().split(",")))
LContactsL.append(set(zip(header,l.rstrip().split(","))))
print(LContacts,'\n',LContactsL[0])
for l in LContacts:
H,F = zip(*l)
print("email:" , F[2] , "--" , F[1], F[0])