-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_matches.py
40 lines (31 loc) · 1.05 KB
/
find_matches.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
# Finds matches between 2 users using the h5 file
from tables import *
import numpy as np
class Track(IsDescription):
song = StringCol(128)
album = StringCol(128)
danceability = Float32Col()
loudness = Float32Col()
acousticness = Float32Col()
instrumentalness = Float32Col()
liveness = Float32Col()
energy = Float32Col()
speechiness = Float32Col()
valence = Float32Col()
tempo = Float32Col()
key = Int32Col()
mode = StringCol(5)
h5file = open_file('output.h5', mode='r', title='Spotify Tracks')
track_names = []
usernames = []
for table in h5file.root.trackinfo:
track_names.append([])
usernames.append(table.name)
for track in table:
track_names[len(track_names) - 1].append(track['song'])
for i in range(len(track_names)):
for it in range(len(track_names)):
if i is not it:
similar = list(set(track_names[i]).intersection(track_names[it]))
print(usernames[i] + " and " + usernames[it] + " have " + str(len(similar)) + " top tracks in common.")
h5file.close()