-
Notifications
You must be signed in to change notification settings - Fork 1
/
Getters.py
78 lines (62 loc) · 2.03 KB
/
Getters.py
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
76
77
78
import csv
import datetime
file = open('movies.csv', encoding='utf8')
dictlist = csv.DictReader(file)
def get_year(value):
for row in dictlist:
if value == row['original_title']:
file.seek(0)
return row['year']
def get_genre(value):
for row in dictlist:
if value == row['original_title']:
file.seek(0)
return row['genre']
def get_duration(value):
for row in dictlist:
if value == row['original_title']:
duration_format = str(datetime.timedelta(minutes=int(row['duration'])))
file.seek(0)
return duration_format
def get_director(value):
for row in dictlist:
if value == row['original_title']:
file.seek(0)
return row['director']
def get_writer(value):
for row in dictlist:
if value == row['original_title']:
file.seek(0)
return row['writer']
def get_production_company(value):
for row in dictlist:
if value == row['original_title']:
file.seek(0)
return row['production_company']
def get_actors(value):
actor_list_final = []
for row in dictlist:
if value == row['original_title']:
actor_str = row['actors']
actor_list = actor_str.split(',')
for i in range (5):
actor_list_final.append(actor_list[i])
file.seek(0)
return actor_list_final
def get_description(value):
for row in dictlist:
if value == row['original_title']:
file.seek(0)
return row['description']
def get_avg_vote(value):
for row in dictlist:
if value == row['original_title']:
file.seek(0)
return row['avg_vote']
## fixa strängformattering på siffrorna
def get_votes(value):
for row in dictlist:
if value == row['original_title']:
file.seek(0)
votes = row['votes']
return votes