CS 204: Software Design

Two unrelated exercises: encoding and XML

Hand in via your Courses Hand-in folder, as toUTF8.py and itunesinfo.py. Develop both of these programs keeping in mind all the design ideas we have been reading and talking about this term.

  1. Write a Python program called "toUTF8.py" that reads data from a text file, automatically detects whether the data is in UTF-8, Latin-1, UTF-16 little endian, or UTF-16 big endian, and prints a UTF-8 version of the input to a new file. Your commandline syntax should be "python toUTF8.py originalfile.txt utf8file.txt".

    Your program will have to make some assumptions in its automatic detection process. Include a discussion of those assumptions in the comment at the top of your source code.

  2. Write a Python program called itunesinfo.py using the xml.dom.minidom module to extract information from an "iTunes Music Library.xml" file. Start work on this program by doing a bit of brainstorming of user stories (what info might people like to easily obtain from their iTunes libraries?). Design a suitable command-line interface to go with your highest priority features, implement the interface (including a usage statement), and implement your features.

    At minimum, your program should provide a usage statement when executed as "python itunesinfo.py --help", and should include a feature that provides summary statistics for the iTunes library file (e.g. number of albums, number of tracks, number of artists).

    If you have trouble finding an "iTunes Music Library.xml" file to work with, let me know.