-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
75 lines (55 loc) · 2.04 KB
/
main.py
File metadata and controls
75 lines (55 loc) · 2.04 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 09 21:28:36 2017
@author: Home
"""
from Owner import Owner
from Dog import Dog
from Cat import Cat
import pandas as pd
Owners = pd.read_csv('owners.csv')
Dogs= pd.read_csv('dogs.csv')
Cats= pd.read_csv('cats.csv')
Owners_dict = {}
Dogs_dict = {}
Cats_dict = {}
def deleteOwner(id):
Owners_dict.pop(id)
def createOwner(Owner):
Owners_dict.update({Owners_dict.keys()[-1] + 1 : Owner})
def updateOwner(id, Owner):
Owners_dict[id]=Owner
def displayOwner(id):
print('Owner Name: ' + str(Owners_dict.get(id).first_name) +" "+ str(Owners_dict.get(id).last_name) )
def listAllOwners():
for key in Owners_dict:
print('Owner Name: ' + str(Owners_dict.get(key).first_name) +" "+ str(Owners_dict.get(key).last_name) )
def deleteCat(id):
Owner_id=Cats_dict.get(id).Owner_id
print(Owner_id)
print(Owners_dict.get(Owner_id).Cats_list).remove(str(id))
def deleteDog(id):
Owner_id=Dogs_dict.get(id).Owner_id
print(Owner_id)
print(Owners_dict.get(Owner_id).Dogs_list).remove(str(id))
def display_cat(id):
print('Cat Name: ' + str(Cats_dict.get(id).name) )
def display_dog(id):
print('Dog Name: ' + str(Dogs_dict.get(id).name) )
def createOwnersFromCSV():
for i in range(len(Owners)):
Owners_dict[Owners.loc[i,'Id']] = Owner(Owners.loc[i,'First Name'], Owners.loc[i,'Last Name'],
Owners.loc[i,'Birthday'],convertToList(list(Owners['Dogs_ids'][i])),
convertToList(list(Owners['Cats_ids'][i])))
def createDogsFromCSV():
for i in range(len(Dogs)):
Dogs_dict[Dogs.loc[i,'Id']] = Dog(Dogs.loc[i,'Name'], Dogs.loc[i,'Birthday'], Dogs.loc[i, 'Owner_id'])
def createCatsFromCSV():
for i in range(len(Cats)):
Cats_dict[Cats.loc[i,'Id']] = Cat(Cats.loc[i,'Name'], Cats.loc[i,'Birthday'], Cats.loc[i, 'Owner_id'])
def convertToList(list):
return [i for i in list if i != ' ']
createOwnersFromCSV()
createDogsFromCSV()
createCatsFromCSV()
#print(Owners_dict.get(1).Cats_list.remove(str(3)))