Skip to main content

08 | Assignment 08

560 "Working with Files" Portfolio Sample

Slide 8 cover

This project involves two versions of the program. The original program which was not as robust as the newer refactored program. This is a good project for understanding the "bigger picture" aspects of programming.

This is a major project. It has elements from the following sessions:

  1. Python Basics
  2. Decision Structures
  3. Repetition Structures
  4. Functions 1
  5. Functions 2
  6. Lists & Tuples
  7. Dictionaries
  8. Files and Exceptions

This project requires collecting several CSV lists. The lists are then presented to the user as choices in a dropdown list.

Here is an example dropdown list based on one student's files:

What file would you like to search for?:
a) 60s-music file
b) athletes file
x) to exit

If the user chooses "a", then the output reads as follows:

Enter the search term for 60s-music.csv file:

If the user searched for beatles then the following output would be printed:

Your search term Beatles exists in the 60s-music.csv file!
Would you like to see the entries? (y or n)?

If the user entered Y or y, then the following would be returned:

Here are all of the entries with the term Beatles:
Hey Jude,The Beatles
I Want to Hold Your Hand,The Beatles
Yesterday,The Beatles
A Day in the Life,The Beatles
Let It Be,The Beatles
Help!,The Beatles
Twist and Shout,The Beatles
I Want to Hold Your Hand,The Beatles
All You Need Is Love,The Beatles
Strawberry Fields Forever,The Beatles

Notice that there is a repition in the file. This is because ChatGPT is not very good at creating a list of items without repetition.

Therefore part of this project may require that you copy your list into excel and do a sort and remove duplicates.

This in-class exercise demonstrates familiarity with

  • import
  • specifically import sys
  • while loop
  • while True:
  • input()
  • '''triple quote string'''
  • if:
  • variables
  • = assignment operator
  • == equals comparison operator
  • sys.exit()
  • elif:
  • else:
  • continue
  • input with variable
  • .title() method
  • f-strings
  • function with arguments (def)
  • global and local scope variables
  • with open / as
  • working with .csv files
  • 'r' read
  • file.read()
  • if / in
  • for line in file
  • line.strip()
  • call function
  • git and GitHub