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:

  1. Read the data using the Python json library.
  2. Retrieve the subset of cards that have “Creature” in the type field.
  3. 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”.
  4. Remove duplicates.
  5. Sort the cards based on alphabetic order of the “name” field.
  6. 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):