File Formats
Overview
- Due:
- 11:00pm, Friday September 25, 2020
- Max grace days:
- 2
The purpose of this assignment is to extract a subset of data from one file format and write it out as another file format.
Description
The assignment material contains a file named M21.json
. This file was obtained from MTGJSON. The file contains a dataset of cards from the game Magic: The Gathering as a JSON file. The goal for this assignment is to extract a subset of card data and output it as a CSV file.
The data processing steps are as follows:
- Read the data using the Python
json
library. - Retrieve the subset of cards that have “Creature” in the type field.
- From the subset of cards obtained in the previous step, we only want to keep the following fields: “name”, “type”, “manaCost”, “convertedManaCost”, “power”, and “toughness”.
- Remove duplicates.
- Sort the cards based on alphabetic order of the “name” field.
- Write the data to a CSV file using the Python
csv
library.
The output file must have the following format: the first line must be
name,type,manaCost,convertedManaCost,power,toughness
and each subsequent line contains the appropriate values in the correct order separated by commas.
You may hard-code the filename in your program. That is, this program is only intended to work with the given dataset.
Turning in the Assignment
You must turn in a file named main.py
. Submit the program source file to the appropriate folder on D2L.
Grading Criteria
Note: If your code does not run on the Python 3 interpreter, then you will receive a failing grade for this assignment.
Grading (out of 100 points):
- 10 points – correct file name
- 10 points – proper Python module conventions
- 20 points – correct use of Python libraries
- 10 points –
json
library - 10 points –
csv
library
- 10 points –
- 60 points – correct output
- 10 points – output file is in CSV format
- 10 points – all “Creature” cards
- 10 points – correct field order
- 10 points – correct field values
- 10 points – duplicates removed
- 10 points – sorted by “name” field