-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathterminal.py
More file actions
executable file
·84 lines (77 loc) · 1.97 KB
/
terminal.py
File metadata and controls
executable file
·84 lines (77 loc) · 1.97 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
76
77
78
79
80
81
82
83
84
import time
import sys
import sqlite3
# conn = sqlite3.connect('top500.db')
import pickle
import math
# c=conn.cursor()
# c.execute('select distinct user_id from reviews where review=1 and movie_id='+str())
# class_1=[]
# class_1=c.fetchall()
#
# for i in range(len(class_1)):
# class_1[i]=list(class_1[i])[0]
# print len(class_1)
#
# c.execute('select distinct user_id from reviews where review=2 and movie_id='+str() ')
# class_2=[]
# class_2=c.fetchall()
#
# for i in range(len(class_2)):
# class_2[i]=list(class_2[i])[0]
# print len(class_2)
#
#
# c.execute('select distinct user_id from reviews where review=3 and movie_id='+str()')
# class_3=[]
# class_3=c.fetchall()
#
# for i in range(len(class_3)):
# class_3[i]=list(class_3[i])[0]
# print len(class_3)
#
#
# c.execute('select distinct user_id from reviews where review=4 and movie_id='+str()')
# class_4=[]
# class_4=c.fetchall()
#
# for i in range(len(class_4)):
# class_4[i]=list(class_4[i])[0]
# print len(class_4)
#
# c.execute('select distinct user_id from reviews where review=5 and movie_id='+str()')
# class_5=[]
# class_5=c.fetchall()
#
# for i in range(len(class_5)):
# class_5[i]=list(class_5[i])[0]
# print len(class_5)
#
#
# conn.close()
conn = sqlite3.connect('top500.db')
c=conn.cursor()
c.execute('select user_id,movie_id,review from reviews limit 100')
#500,1000,5000 db
#50,100,250,500
results=c.fetchall()
for i in range(len(results)):
results[i]=list(results[i])
results.sort(key=lambda x: x[1])
movie1=[]
movie2 = []
movie3 = []
for i in range(len(results)):
if results[i][1] == 1:
movie1.append([str(results[i][0]),str(results[i][2])])
elif results[i][1] == 2:
movie2.append([str(results[i][0]),str(results[i][2])])
else:
movie3.append([str(results[i][0]),str(results[i][2])])
all_movies = []
all_movies.append(["1",movie1])
all_movies.append(["2",movie2])
all_movies.append(["3",movie3])
with open("test_movies","wb") as f:
pickle.dump(all_movies,f)
conn.close()