-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErotima4.py
More file actions
52 lines (46 loc) · 1.71 KB
/
Erotima4.py
File metadata and controls
52 lines (46 loc) · 1.71 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
import csv
import AstraConnect
import GlobalVariables as GV
import time
from cassandra.concurrent import execute_concurrent_with_args
def InsertTitle(profile, truncate):
startTime = time.time()
session = AstraConnect.AstraConnect(profile)
if (truncate):
session.execute('TRUNCATE movie_database.MovieTitle')
movieTitles = []
with open(GV.CSVPATH+'fulldetails.csv', 'r') as input:
csv_reader = csv.reader(input, delimiter=',')
for row in csv_reader:
tempList = [int(row[0]), row[1]]
movieTitles.append(tempList)
insertTitles = session.prepare('INSERT INTO movie_database.MovieTitle (movieId, title) VALUES (?, ?)')
execute_concurrent_with_args(session, insertTitles, movieTitles, 90)
endTime = time.time()
file = open("TimeComparison.txt", 'a')
file.write(AstraConnect.ProfileToString(profile) + " time: %f\n" % (endTime-startTime))
file.close()
def SelectTitle(profile, word):
session = AstraConnect.AstraConnect(profile)
query = session.prepare("SELECT title FROM movie_database.MovieTitle")
startTime = time.time()
duration = []
results = []
results.append(session.execute(query))
exportedList = []
for row in results:
for element in row:
exportedList.append(element[0])
exportedList.sort()
titlesList = []
for i in range(0, len(exportedList)):
if (word in exportedList[i]):
titlesList.append(exportedList[i])
#file = open("Erotima4output.txt", "a")
#for i in range(0, 5):
#file.write(titlesList[i]+"\n")
#file.close()
duration = time.time() - startTime
file = open('Erotima4.txt', 'a')
file.write(f"{duration}\n")
file.close()