Question: Objective Create a Python program that manages CSV file operations, uses the os module to interact with the file system, and separates data definition into

Objective
Create a Python program that manages CSV file operations, uses the os module
to interact with the file system, and separates data definition into a module. You
will also create another file called csv_data.py to store all your data that you will
use when creating your CSV file.
Global Variable
Setstring main.py equal to a global variable called filepath and run that through
the following functions you create
SampleDataDictionary
Create a new file called csv_data.py, define a data dictionary with at least 3 fields
and 5 entries, which will be imported into main.py.
CSVFileCreation and Reading
Write a function called create_csv() to create a CSV file from a data dictionary
imported from csv_data.py.
NamedtheCSVfile csv_data.csv
Usecsv.DictWriter to write the data to the CSV file within a with statement
ensuring proper file handling.
File Existence Check
Create a function called file_exists()
Usetheos.path.exists module to check if the main.py file exists.
File Metadata
Create a function call file_metadata()
Useos.stat to obtain and print the file size and last modified time of main.py.
ReadandDisplay CSV Data
Create a function called read_csv()
Thisfunction should open the created CSV file and uses csv.DictReader within a
with statement to iterate over and print each row.
Useaforloop to iterate through each row in the csv file and print the output on
the console
MainFunction
Create a function called main()
Call on all functions that were created through the main function
Remembertocall on the main function to run your python scrip

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!