-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroughlibrary.py
More file actions
71 lines (63 loc) · 2.42 KB
/
roughlibrary.py
File metadata and controls
71 lines (63 loc) · 2.42 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
import pandas as pd
library_file = 'out.csv'
searchbase = pd.read_csv(library_file, sep=';', encoding='UTF-8', names=['Title', 'Players', 'Timelapse', 'Age'])
def menu_options():
print("""Välj mellan alternativen
1. Lägg till spel
2. Ändra titel
3. Ändra spelare
4. Ändra Tid
5. Ändra Ålder
6. Spel från x ålder
0. Avsluta
""", end="Svar: ")
pick = int(input())
return pick
def menu_handler(searchbase):
pick = None
while pick != 0:
pick = menu_options()
## Add game
if pick == 1:
title = input("Title: ")
if title in searchbase.Title.values:
print('Title exists')
break
try:
players = int(input("Players: "))
timelapse = int(input("Timelapse: "))
age = int(input("Age: "))
searchbase = searchbase.append([{'Title': title, 'Players': players, 'Timelapse': timelapse, 'Age': age}], ignore_index=True)
except:
print('Something went wrong')
continue
if pick == 2:
title = input("Title: ")
if title in searchbase.Title.values:
new_title = input("New title: ")
if new_title in searchbase.Title.values:
print('Title exists')
break
searchbase.Title = searchbase.Title.replace(title, new_title)
print(searchbase)
if pick == 3:
title = input("Title: ")
if title in searchbase.Title.values:
new_players = int(input("New players: "))
searchbase.loc[searchbase.Title == title, 'Players'] = new_players
if pick == 4:
title = input("Title: ")
if title in searchbase.Title.values:
new_timelapse = int(input("New timelapse: "))
searchbase.loc[searchbase.Title == title, 'Timelapse'] = new_timelapse
if pick == 5:
title = input("Title: ")
if title in searchbase.Title.values:
new_age = int(input("New age: "))
searchbase.loc[searchbase.Title == title, 'Age'] = new_age
if pick == 6:
entry = int(input("Från ålder: "))
print(searchbase[searchbase.Age > entry])
print(searchbase)
searchbase.to_csv(library_file, sep=';', encoding='UTF-8', index=False, header=None)
menu_handler(searchbase)