Simple array based database

Simple Array Based Database

Solution

 backup.py

 fp  = open(‘InputFile.txt’)

line = fp.readline()

title = []

artist = []

genre = []

for line in iter(fp):

words = [words.strip() for words in line.split(‘|’)]

title.append(words[0])

artist.append(words[1])

genre.append(words[2])

fp.close()

defsearchTitle():

count=int(0)

print(” You are searching for the Title here”)

title1=input(“\n Please enter the Title to Search : “)

for i in range(len(title)):

if title1 in title[i].lower():

print(“(“,genre[i],”)”,title[i],” by “,artist[i])

count=count+1

print(count,” records retrived “)

defsearchArtist():

count=int(0)

print(” You are searching for the Artist name here”)

name=input(“\n Please enter the Artist name to Search : “)

for i in range(len(artist)):

if name in artist[i].lower():

print(“(“,genre[i],”)”,title[i],” by “,artist[i])

count=count+1

print(count,” records retrived “)

defsearchGenre():

count= int(0)

print(” You are searching for the Genre here”)

genre1=input(“\n Please enter the Genre to Search : “)

for i in range(len(genre)):

if genre1 in genre[i].lower():

print(“(“,genre[i],”)”,title[i],” by “,artist[i])

count=count+1

print(count,” records retrived\n”)

ans=True

print(“!!!! Your favouritePlayList !!!!”)

whileans:

print(“””

1.Title

2.Artist

3.Genre

4.Exit

“””)

ans=input(“Please Select any Option : “)

ifans==”1″:

searchTitle()

elifans==”2″:

searchArtist()

elifans==”3″:

searchGenre()

elifans==”4”:

print(“\nGood Bye!!!”)

ans= None

elifans !=””:

print(“\n Not a Valid Choice Choose between 1 to 4 Try again”)

relation.py

 filename=input(‘Please enter file name (Include the .extension as well example InputFile.txt ) : ‘)

fp  = open(filename)

line = fp.readline()

title = []

artist = []

genre = []

for line in iter(fp):

words = [words.strip() for words in line.split(‘|’)]

title.append(words[0])

artist.append(words[1])

genre.append(words[2])

fp.close()

defsearchTitle():

count=int(0)

print(” You are searching for the Title here”)

title1=input(“\n Please enter the Title to Search : “)

for i in range(len(title)):

if title1 in title[i].lower():

print(“(“,genre[i],”)”,title[i],” by “,artist[i])

count=count+1

print(count,” records retrived “)

defsearchArtist():

count=int(0)

print(” You are searching for the Artist name here”)

name=input(“\n Please enter the Artist name to Search : “)

for i in range(len(artist)):

if name in artist[i].lower():

print(“(“,genre[i],”)”,title[i],” by “,artist[i])

count=count+1

print(count,” records retrived “)

defsearchGenre():

count= int(0)

print(” You are searching for the Genre here”)

genre1=input(“\n Please enter the Genre to Search : “)

for i in range(len(genre)):

if genre1 in genre[i].lower():

print(“(“,genre[i],”)”,title[i],” by “,artist[i])

count=count+1

print(count,” records retrived\n”)

ans=True

print(“!!!! Your favouritePlayList !!!!”)

whileans:

print(“””

1.Title

2.Artist

3.Genre

4.Exit

“””)

ans=input(“Please Select any Option : “)

ifans==”1″:

searchTitle()

elifans==”2″:

searchArtist()

elifans==”3″:

searchGenre()

elifans==”4”:

print(“\nGood Bye!!!”)

ans= None

elifans !=””:

print(“\n Not a Valid Choice Choose between 1 to 4 Try again”)