Python ''' You are expected to comment your code. At a minimum if statements and for loops need at least 1 line of comment to explain what the loop does''' #------------IMPORT ANY LIBRARIES YOU NEED HERE----------- #---------- CREATE YOUR CUSTOM EXCEPTION HERE------------- class NotAValidDirectory(Exception):     pass '''Write a function that reads all the text files (.txt extension) located in the directory myPath and writes it to a new Combined file created in the current directory. It returns the values defined below. You will raise a custom exception called "NotAValidDirectory"if the directory provided is not a directory.(Note you will need to create the custom exception called NotAValidDirectory yourself. ''' def combineFiles(directoryName,combinedFilename): '''Use these provided variables and update them with the information described in the comment associated with each variable.'''     totalFileCount = 0 #contains the total number of files in the directory provided      textFileCount = 0 # provides the number of text files found in the directory     combinedFileLineCount = 0 #provides the total number of lines in the final combined file #----------------YOUR FUNCTION CODE STARTS HERE--------------- #------------------- YOUR FUNCTION CODE ENDS HERE------------------     return totalFileCount, textFileCount,combinedFileLineCount '''This will run your program. You should only add code to handle exceptions that are raised. Any exceptions found will only display "Exception Found" and end program execution. The program will only run once.(Does not automatically restart)''' if __name__ == "__main__":     directoryName = input("Directory: ")     combinedFilename = input ("Combined Filename: ")     print(combineFiles(directoryName,combinedFilename))

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Python

''' You are expected to comment your code. At a minimum if statements and for loops
need at least 1 line of comment to explain what the loop does'''

#------------IMPORT ANY LIBRARIES YOU NEED HERE-----------

#---------- CREATE YOUR CUSTOM EXCEPTION HERE-------------
class NotAValidDirectory(Exception):
    pass

'''Write a function that reads all the text files (.txt extension)
located in the directory myPath and writes it to a new Combined
file created in the current directory. It returns the values
defined below. You will raise a custom exception called "NotAValidDirectory"if the directory provided
is not a directory.(Note you will need to create the custom exception called NotAValidDirectory yourself.
'''
def combineFiles(directoryName,combinedFilename):
'''Use these provided variables and update them with the information described in the comment
associated with each variable.'''
    totalFileCount = 0 #contains the total number of files in the directory provided
     textFileCount = 0 # provides the number of text files found in the directory
    combinedFileLineCount = 0 #provides the total number of lines in the final combined file

#----------------YOUR FUNCTION CODE STARTS HERE---------------


#------------------- YOUR FUNCTION CODE ENDS HERE------------------
    return totalFileCount, textFileCount,combinedFileLineCount


'''This will run your program. You should only add code to
handle exceptions that are raised. Any exceptions found will only
display "Exception Found" and end program execution. The program will
only run once.(Does not automatically restart)'''
if __name__ == "__main__":
    directoryName = input("Directory: ")
    combinedFilename = input ("Combined Filename: ")
    print(combineFiles(directoryName,combinedFilename))

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY