So I am given a CSV file which catalogs some 1000 songs, the data given is the Artist, Album, Song_Title, and Duration of the songs in seconds.
I import the CSV file by doing the following:
column_names = ['artist', 'album', 'song_title', 'duration']
track_list = pd.read_csv('/Users/Basel/Desktop/Class Files/JukeBoxHero/music-collection.csv', names=column_names,
header=None)
for reference, this is an example of a line from the CSV file:
Aerosmith,A Little South Of Sanity Disc 1,Falling In Love (Is Hard On The Knees),209
The function I am attempting to use to allow the user to enter a search term and get a list of all the songs which have the search term in their names goes as follows:
def findSongs(songList):
searchTerm=input("searching for?")
for songs in songList:
if searchTerm in songs:
print("-----------------------")
print("Artist: " + currentSong['artist'])
print("Album: " + currentSong['album'])
print("Title: " + currentSong['song_title])
print("Duration: " + currentSong['duration'] + "seconds")
However, when I try to call the function with print(findSongs(track_list)) the terminal always seems to output None. My guess is that there is something wrong in the way I am structuring my for-loop but I have spent a lot of time trying out different variables and trying to use integer indexes all to no avail.