I have 2 text files and I need to grab a value from fileA, match it with fileB and print the result.
fileA contains userID, artistID and how many times artistID has been played. fileB contains artistID and the name of the artist.
I need to write a function that will tell me how many times a certain user has played an artist. I need to print the name of the artist and the number of times. I got the pseudocode done but having trouble moving forward.
def printListenersTimesPlayed(userID)
find all artists and number of time they've been played from fileA
find the name of the artist from fileB
print list of artists and times that the user (userID) has played
when someone types a userID (example: 1000002) it should print out for example Pearl Jam, 55.
any help is appreciated!
and here's what i have so far:
fileA contains userID, artistID and how many times artistID has been played. fileB contains artistID and the name of the artist.
I need to write a function that will tell me how many times a certain user has played an artist. I need to print the name of the artist and the number of times. I got the pseudocode done but having trouble moving forward.
def printListenersTimesPlayed(userID)
find all artists and number of time they've been played from fileA
find the name of the artist from fileB
print list of artists and times that the user (userID) has played
when someone types a userID (example: 1000002) it should print out for example Pearl Jam, 55.
any help is appreciated!
and here's what i have so far:
file1 = open("user_artist_data.txt", "r") file2 = open("artist_data.txt", "r") users = [line.split(' , ')for line in file1] print(file1) artist = [line.split(' , ') for line in file2] print(file2) #for values in file1, grab the same value from file2 and print the result. def printListenersTimesPlayed(): print()