-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.py
More file actions
30 lines (27 loc) · 875 Bytes
/
db.py
File metadata and controls
30 lines (27 loc) · 875 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
28
29
30
from CaseStudyModule_PlayerClass import *
import csv
#intakes list and imports to a .csv file
def write(x):
with open("player_list.csv", 'w' , newline="") as file:
writer = csv.writer(file)
players = []
for y in x:
player = []
player.append(y.FirstName)
player.append(y.LastName)
player.append(y.Position)
player.append(y.AtBats)
player.append(y.Hits)
players.append(player)
writer.writerows(players)
def read():
try:
playerlist = []
with open("player_list.csv", newline="") as file:
reader = csv.reader(file)
for row in reader:
player = Player(row[0], row[1], row[2], row[3], row[4])
playerlist.append(player)
except:
print()
return playerlist