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