-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComicAccess.py
More file actions
26 lines (17 loc) · 766 Bytes
/
ComicAccess.py
File metadata and controls
26 lines (17 loc) · 766 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
import pandas as pd
import random
class ComicAccess():
csv = pd.read_csv(r'comic_rating.csv')
def saveCsv(self):
self.csv.to_csv(r'comic_rating.csv', header = True, index = False)
def getRandomComic(self):
random_comic = self.csv.iloc[random.randint(0,self.csv.shape[0]-1)]
return random_comic
def updateElo(self, index, elo):
self.csv.loc[index,"Score"] = elo
self.saveCsv()
def addNew(self,title,writer,artist,year,issues,score):
new_row =pd.DataFrame({"Title":[title],"Writer":[writer],"Artist":[artist],"Year":[year],"Issues":[issues],"Score":[score]})
self.csv = pd.concat([self.csv, new_row], axis = 0, ignore_index = True)
print(self.csv)
self.saveCsv()