Link Search Menu Expand Document

CSV Processing

GitHub Assignment

For this assignment you will implement and four functions and you may work in groups of two to three.

This assignment involves reading data from a CSV file to implement functions that can retrieve information about our dataset of video game sales data. Your functions will be implemented in the file vg_data.py and this time you will not have to write test cases, but you will need to verify your solutions with the main.py tests (uncomment the tests as you complete the respective functions).

vg_data.py contains function definitions and docstrings for the four functions that you are to write. Read the docstrings to see what the functions are supposed to do. MAKE SURE TO IDENTIFY YOUR GROUP MEMEBERS IN A COMMENT AT THE TOP OF vg_data.py.

You may need to search online to figure out how to implement some of the functions. If you are new to Python or want a more complete overview of the basics of Python, see the official Python tutorial: https://docs.python.org/3.9/tutorial/index.html

HINTS:

  • The sorted and sort functions are helpful…especially the optional key parameter. There is some good documentation on these functions here: https://realpython.com/python-sort/
  • Remember that by default your csv data will be text…you may need to convert it to another type to work with it for some functions
  • Look at the following GitHub repository examples:
    • DictReader example in pyhton/examples/csvfiles/csv_reading.py
    • Sorting example in python/examples/sorting/sort_example.py

Validation

You need to have pytest, pytest-timeout and pycodestyle python packages installed. Install them running

pip install pytest pytest-timeout pycodestyle

Run locally from the terminal window:

  • pytest - to run the unit tests
  • pycodestyle vg_data.py - to check for PEP8 style errors

Submission

Commit your changes to the 2 Python files and push your code to GitHub. Tests will be run on your code and notify you if it passed.

Follow all naming conventions from class and the slides!

  • Variables are underscore = my_variable
  • Functions are also underscore = my_function()

If the tests all pass you should see something like this:

❯ pytest
======= test session starts ==============================================
platform darwin -- Python 3.8.13, pytest-7.2.1, pluggy-1.0.0
rootdir: /cs232/github-classroom/autograding-csv-processing
plugins: timeout-2.1.0
collected 4 items                                                                                                                                                                                           

vg_data_test.py ....                                                                                                                                                                                  [100%]

================= 4 passed in 0.59s ===========================================

If there are any failures you will see additional information about each failure.

The pep8 utility will also be run on your code to ensure that it conforms to the PEP 8 style guide. For full credit your code must pass all the tests and adhere to PEP 8. Each PEP 8 warning will tell you the filename, line number, and reason for the voliation in the messages. Below is an example where the line of code was too long in the my_functions.py file on line 76.

vg_data.py:19:5: E113 unexpected indentation

Grade: 20 points

  • 1 point - work submitted
  • 7 points - functions implemented
  • 7 points - functions pass all tests (main.py and automated tests)
  • 5 points - Submission does not have any PEP 8 violations and follows the established naming conventions