Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How would i run this program and can someone help fill in missing portions since im super bad at coding. Note this is PYTHON. import
How would i run this program and can someone help fill in missing portions since im super bad at coding. Note this is PYTHON.
import os from hw1 import run def hw_main(): """ Main function for HW1. Add any new (added) function calls to this method. :return: None """ path = 'C:/Users/mini/Desktop/uni/coding/hw1/Random_Files' print("HW1 main function") # add lines to this function before it ends at the return below # create your own functions and use them to accomplish your goals! print("Creating random data files") # Goal 1) # Create a for loop that calls run() 5 times # add print text to the loop, to clarify to the user current loop #1 for file in range(1): # repeat hw1_lecture 5 times run() print(file) # prints output print("Finding Random Files") # Goal 2) # use the os module to list all files in the "/Random_Files/" folder # be sure to carefully record paths to files # print the # of files files = os.listdir(path) #directorty to files on my PC for f in files: print(f) #prints files in defined folder print("Sorting by file type") # Goal 3) # sort files found in the "Random_Files" folder by file type (.csv, .html, .xlsx, .png, .jpg) # collect paths to all files of a specific type grouped in a data structure # for example: a numpy array containing paths to all .csv or a list containing all paths to .png, etc. print("Making Sorted Directories") # Goal 4) # create directories for each file type at the same level as "Random_Files" folder # (inside this script's working directory) # Be sure to make this script re-usable and protect os.mkdir() with try/except print("Sorting Random_Files") # Goal 5) # Move the sorted files into the new directories (all .csv in the CSV directory and so on) # This can be done as a copy then delete the original, or move print("Removing old directory") # Goal 6) # delete the Random_Files directory print("HW1 Script Complete!") return if __name__ == '__main__': print("Starting HW1 Script") hw_main()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started