Python代写:CS1110 Decoding Data



For this project, you will get some more practice working with data. Suppose that you are given a file containing the details of players of a NFL team roster.

The data is consistently organized in the form of XML tags in the following manner:

  • The first/root tag contains the details of the team
  • The name tag of a team, [name], contains the team’s name
  • The players tag of a team, [players], contains a list of player details
  • The player tag, [player], contains the following information about each player
    • Jersey Number
    • First Name
    • Last Name
    • Height (Feet-Inches)
    • Weight (Pounds)
    • Age
    • Position
    • School

Your job is to write a python program, called summarizeData(filename), that takes, as an argument, the name of a file. In all cases, this file will be a .txt file. For example, this function would be called using the following:

>>> summarizeData("Broncos.txt")

You CANNOT just hard-code the name of the file into the program, nor should you overwrite the name of the file in your program! It must be passed in as the argument in the function. Your program will open the file and create a new file with a summary of the data, with the tags stripped from the data, as specified below. The name of this new file must be a modification of the file name that contains the data (which is passed as an argument when calling this function). For example, if the name of the original data file is called “Broncos.txt”, the new file name should be “BroncosRoster.txt”. If the data file is called “Bills.txt”, the new file name should be “BillsRoster.txt”.

The output for the example file above should be in the following format (items in bold depend on the contents from the file (the bold font is just to point out the data that is being supplied by the file), and you cannot assume that there only 3 players in a given file! You must open the file and count them!):

Here is the roster for the Denver Broncos. There are 3 players on the team. Zaire Anderson, ILB, wears #50. He is 5 foot 11 inches tall, and weighs 220 pounds. He is 24 years old. He went to Nebraska. Shaquil Barrett, OLB, wears #48. He is 6 foot 2 inches tall, and weighs 250 pounds. He is 23 years old. He went to Colorado State. Kapri Bibbs, RB, wears #48. He is 5 foot 11 inches tall, and weighs 203 pounds. He is 23 years old. He went to Colorado State.

I made the font small, so that you could see the new lines. Only include one space between a period and the first word of the next sentence. However, there should be no space before a new line. Also, include one space between a comma and the next word. Exact punctuation is required. Remember to include commas, periods, and spaces. There should be a new line after the school information for a given player. Those should be the only new lines that you encode. Remember that the grading of these projects will have an automated component. If any of these directions are not clear, please ask for clarification.

It is important that the name of the output file follow the naming structure specified. As another example, if the file being opened is “Chargers.txt”, the name of the output file should be “ChargersRoster.txt”. In other words, the name of the output file should be the name of the input file with Roster added on to it (before the .txt ending).

Submit ONE file (the .py file) to the assignment folder on ICON prior to the deadline. After the deadline, no submissions will be accepted. Be sure to follow the naming conventions that have been used throughout the semester:

At the beginning of your python file, be sure to include a function that returns a list containing your HAWKID. This is important, so I will write it in all capsI am not yelling at youI am trying to get your attention. BY NOW, YOU SHOULD KNOW HOW TO WRITE THIS FUNCTION. IF YOU CANNOT WRITE THIS FUNCTION, YOU WILL NOT RECEIVE ANY CREDIT FOR YOUR SUBMISSION. Seriously. Be sure to include this function, or you won’t have your grade on the project entered into the grade book. This function should be named getHawkIDs().

Make sure that you submit the correct file. The file that you submit will be the file that is graded. If you submit a file that is incomplete, that is the one that will be graded, regardless of whether or not you have a more complete project that you meant to submit. Date and time stamps on a file are irrelevant…the only file that matters is the .py file that you submit through ICON before your access to this folder closes. You may submit your file more than once, but only the most recent file will be stored in the assignment folder, and only the most recent file submitted will be graded.

This is an individual project. Do not talk with your classmates or roommates about the project. Do not search for a solution on the Internet (this does not mean that you cannot look up information about python functions, like split() and strip() ). This project is your chance to show your programming skills. I am not interested in grading the Internet community, or your roommate. I am interested in grading YOUR work. I cannot do that if you get outside help. You can talk with the TAs about the project, but they will be limited in how they help you. But they CAN help you. Please ask them questions or get help. This is your project, after all. You can also talk with me about your project. Do not procrastinate. Finish this project early and get it crossed off of your list. If you are confused about anything, ask! But don’t wait until the day it is due!

For the last two weeks of discussion, you are encouraged to attend multiple discussion sections. The TAs will walk through some examples of how to work with files. Attend several sections if it will help reinforce the ideas behind working with files. Just remember that this is an INDIVIDUAL project. They will also give examples of the strip() and split() functions that Python has (which you can also read about on
The grading rubric for this project is:

  • The program runs without errors. Press the green arrow and look for error messages!
  • The program can open, read, write, and close a file. Be sure to close the files when you are finished.
  • The data is read and interpreted correctly.
  • The sentence structure is correct.
  • Your program is properly documented (i.e. comments)!
  • Your file contains a function that takes no arguments, and returns a LIST containing your hawkID. This function must be named getHawkIDs().