Programming Homework Help

ENTD 220 APUS Week 8 Python Program Project

 

This week you will write a program to read and write from a file.

  1. Copy the following text to a text file (not Word!) and save it as Authors.csv to the file where your .py files are located.

    AuthorID,FirstName,LastName,Country

14,Alysha,Thompson,Canada

18,David,Wright,Canada

6,Dylan,Garcia,Spain

3,Elena,Martin,Mexico

16,Emily,Clark,USA

23,Emily,Murphy,USA

9,Fabian,Wilson,USA

20,Helena,Adams,Canada

7,Ian,Cruz,Mexico

15,Isabella,Lee,Canada

17,John,Young,China

22,Liam,Parker,Canada

10,Liam,Taylor,Canada

12,Logan,Moore,Canada

8,Lucas,Smith,USA

  1. Create a menu using a list to display to the user
    1. “1) Read File; 2) Update the File; 3) Quit
    2. Incorporate looping! Go back to main menu (using the continue y/n features you have added in previous weeks)
  2. create a class wrfile() with two methods to write the results to a file, and to read the results from a file.
    1. Based on user input, call the correct function
  3. When displaying results:
    1. Read one line at a time (hint, use import csv functions!)
    2. Use the translate() string method to get rid of the quotes and brackets in the output
    3. Be sure to close the file when done loading for display
  4. When updating the file:
    1. Update the file by adding some more authors. You can hard-code this and add multiple lines via list. E.g., two more authors are added in this statement:
    2. [[99, “James”, “Joyce”, “UK”], [100, “Ann”, “Cleeves”, “UK”]]
    3. Add more records than these sample ones, please.
    4. Show the file has updated.
    5. Close the file!