Hello I am trying to get def automated(filename): to read an imported text document and have have it make a playlist based upon the specified genre and playlist time. Example is if you decide upon 20 minutes and blues as a genre, the program randomly chooses songs that total up to 20 minutes as close as possible. There is no sample output as def automated isn't set up and configured yet. For this python program you have to choose a file to open first then run automated song choice. Automated is the one I am trying to get working def automated(filename):     try:         print(filename)     except FileNotFoundError:         print('Document not found.') def main():     filename = ''     import case     print("\n\tPlaylist Manager")     print('-'*45)     print('\tWhich Program do you want to run?')     choice = ''     while choice.upper() !='Q':         print()         print('current file opened:', filename)         print('0) choose a file to open')         print('1) automated song choice')         print('2) Special song choice')         print('3) manual song choice')         print('4) Current song playing')         print('5) Save Song Playlist')         print('Q) Quit')         choice=input('Enter a choice: ')         if choice == '0':             print()             filename =input('Enter file name: ')             print('filename saved as', filename)         elif choice == '1':             print()             automated(filename)         elif choice == '2':             print()             special_song(filename)         elif choice == '3':             case.manual_choice(filename)         elif choice == '4':             print()             current_song(filename)         elif choice == '5':             print()             save_playlist()         elif choice.upper() == 'Q':             print("Program complete.")         else:              print('Invalid choice.') main() contents of imported case.py def manual_choice(filename):     try:         rfile = open(filename, 'r')         line_list =rfile.readlines()         for index in range(len(line_list)):             line_list[index] =line_list[index].rstrip('\n')                for song in line_list:             words_list=song.split(' ')                    song = input('What song are you looking for?: ')         if song in rfile:             print(song, 'is in the file', filename)         else:             print(song, 'does not appear to be in the file', filename)     except FileNotFoundError:         print('there is no such file named', filename)        contents of text document Alternative Bastille Pompeii 3:34 Happier 3:34 Of The Night 3:33 Panic! At The Disco I Write Sins Not Tragedies 3:06 Nine in the Afternoon 3:11 High Hopes 3:10 Blues Tab Benoit Nothing Takes The Place Of You 4:01 For What It's Worth 5:17 Shelter Me 5:05 Joe Bonamassa I'll Take Care Of You 5:41 The Heart That Never Waits 5:51 Notches 7:04 Robert Cray Right Next Door (Because of Me) 4:21 Smoking Gun 4:05 This Man 5:06

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hello I am trying to get def automated(filename): to read an imported text document and have have it make a playlist based upon the specified genre and playlist time. Example is if you decide upon 20 minutes and blues as a genre, the program randomly chooses songs that total up to 20 minutes as close as possible. There is no sample output as def automated isn't set up and configured yet. For this python program you have to choose a file to open first then run automated song choice. Automated is the one I am trying to get working

def automated(filename):
    try:
        print(filename)
    except FileNotFoundError:
        print('Document not found.')

def main():
    filename = ''
    import case
    print("\n\tPlaylist Manager")
    print('-'*45)
    print('\tWhich Program do you want to run?')
    choice = ''
    while choice.upper() !='Q':
        print()
        print('current file opened:', filename)
        print('0) choose a file to open')
        print('1) automated song choice')
        print('2) Special song choice')
        print('3) manual song choice')
        print('4) Current song playing')
        print('5) Save Song Playlist')
        print('Q) Quit')
        choice=input('Enter a choice: ')
        if choice == '0':
            print()
            filename =input('Enter file name: ')
            print('filename saved as', filename)
        elif choice == '1':
            print()
            automated(filename)
        elif choice == '2':
            print()
            special_song(filename)
        elif choice == '3':
            case.manual_choice(filename)
        elif choice == '4':
            print()
            current_song(filename)
        elif choice == '5':
            print()
            save_playlist()
        elif choice.upper() == 'Q':
            print("Program complete.")
        else:
             print('Invalid choice.')

main()

contents of imported case.py

def manual_choice(filename):
    try:
        rfile = open(filename, 'r')
        line_list =rfile.readlines()
        for index in range(len(line_list)):
            line_list[index] =line_list[index].rstrip('\n')
      
        for song in line_list:
            words_list=song.split(' ')
          

        song = input('What song are you looking for?: ')
        if song in rfile:
            print(song, 'is in the file', filename)
        else:
            print(song, 'does not appear to be in the file', filename)
    except FileNotFoundError:
        print('there is no such file named', filename)
      

contents of text document

Alternative
Bastille
Pompeii
3:34
Happier
3:34
Of The Night
3:33
Panic! At The Disco
I Write Sins Not Tragedies
3:06
Nine in the Afternoon
3:11
High Hopes
3:10

Blues
Tab Benoit
Nothing Takes The Place Of You
4:01
For What It's Worth
5:17
Shelter Me
5:05
Joe Bonamassa
I'll Take Care Of You
5:41
The Heart That Never Waits
5:51
Notches
7:04
Robert Cray
Right Next Door (Because of Me)
4:21
Smoking Gun
4:05
This Man
5:06

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education