Question: + ID Page view A Read aloud Overview For this assignment you will be reading data from a file located on the internet. The file

 + ID Page view A Read aloud Overview For this assignmentyou will be reading data from a file located on the internet.The file is a listing of people's name, their blithdays and an

+ ID Page view A Read aloud Overview For this assignment you will be reading data from a file located on the internet. The file is a listing of people's name, their blithdays and an ID number in CSV format. This me, however, has some problems with Mosty, some of the birthdays are in an Invalid format The other columns in the CSV will be guaranteed to be in a proper format. so your code can assume so Using the modules that we learned about you will design a program to do two things: witte an output file recording which lines in the file cannot be processad correctly due to an improperty formatted date, and alow a user to enter in an ID number and print out that person's Information Usaful Reminders 1. Read the assignment over a few times. At least twice. I always helps to have a clear picture of the overall assignment when understanding how to build a solution 2 Think about the problem for a while, and even try writing or drawing a solution using pencil and paper or a whiteboard 3. Before submitting the assignment, review the "Functional Requirements" section and make sure you hit all the points. This will not guarantee a perfect score, however Part 0 -Prerequisites 1. Our first step will be to create a github repo for this assignment. Please call it 18211_Assignment2 2 After that is completed, use it to clone this repository to a local folder in your development environment. Al development will be in this directory Part1 - Think about Design When approaching programming problems, you should first step back and think about the problem at hand. What exactly are we trying to accomplish, and what would be a good structure for your program? How would you break the larger problem into a set of smaller steps? One thing to think about in this case, is how you will want to store this data after reading it from the CSV Part I-Download the Data Write a function called download Data which takes in a string called uit. The purpose of this function is to download the contents located at me urt and return it to the cater. You should use urilib2 for this. Do not catch any exceptions here, as this will be done tater Partill - Process Data Witte a function called processData, which takes the contents of the file as the first parameter, processes the file ina byline, and retumsa dictionary that maps a person's D to a tuple of the form (name, birthday). The birthday needs to be a Datetime object, not a string. You will have to process the birthday, which has a format of odmmyyyy, and convert it into a Datetime object (NOTE: the time portion of the Datatimo object will be 0. since we are not setting a time, just a date: you can use the Date object Instead, you feel comfortable doing so) As stated above, the birthday might not be in a correct format. This might be due to a typo in the data (.o., a missing forward slash as in 0304.2014) or an invalid dato (le 04/13/2014). If this is the case, we want bg this oror using the logging module. This function should get a logger using the namo 'assignment. This logger will be configured later in the program The log massage should be sent to the ERROR level, and of the format "Error processing line nenum> for ID #cid>, where and are the line number and ID, respectively, of the person in the CSV file that has a malformed date. Food For Thought There are many ways to represent that data in the CSV Ne using the basic Python data types. Why did we choose to store the data in the form of a dictionary that maps IDs to fupins? No need to submit this, but think about why this was chosen Feel free to post about this in the weekly discussion board Part IV - Display User Input Write a function called displayPerson, which takes in an integer called id as its first parameter, and a dictionary as its second parameter, called personData. The purpose of this function is to print the name and birthday of a given user identified by the input id if there is not entry with the given id, then print "No user found with that instead Otherwise the format should be "Person #id> is with a birthday of date where is the sid>The user requested name is the name of the person (from the file) and date is the birthday of the user formatted as YYYY-MM-DD. NOTE: there is no time being displayed) Part V. Putting it all together We now need to piece all these functions together. Lets write a main function that is called when our script 2 First your program should use the argparse module to allow the user to send a-url parameter to the script. This parameter is a string and is required by the program. If no-urf is given the program should exit Then we need to all the downloadData() function and save the results to a variable. Lets call this variable ca.Data. The URL to pass to downloadData() is the URL given as a parameter to the trict via garse Also we need to ensure that any exception is thrown by this function that we catent.print out an appropria enor message and exit the program We need to set up a logger with name assignment which should be configured to write to a ingre fit called "eron logThis can be done in a separate function of done in the main program Next we need to take care and pass the processData() function. The result of this can should be said to varat cated person Remember this is a dictionary that maps is to fupes + 5. Next, ask the user for an ID to lookup a the user enters in a negative number or 0, exit the program b. the user enters in a positive number, uso displayPerson to attempt printing out the user c Keep asking the user for input until they enter in a negative number or 0 to act Functional Requirements: In this section, we wil outline the various behaviours the program must do in order to get credit, and how we will be checking that these behaviours work correctly 1 The program must accept and use the url parameter. We will use this to point to not only the file in this assignment, but to another fie you will not be able to see beforehand. The program should give correct output in both cases 2 The program must write to a file named error dog 3. Each line of this error file must be of the correct format as specified in Part II 4. The program must print out users in the correct format, as directed by the user input 5. The program must exit only when the user enters in a number 0 + ID Page view A Read aloud Overview For this assignment you will be reading data from a file located on the internet. The file is a listing of people's name, their blithdays and an ID number in CSV format. This me, however, has some problems with Mosty, some of the birthdays are in an Invalid format The other columns in the CSV will be guaranteed to be in a proper format. so your code can assume so Using the modules that we learned about you will design a program to do two things: witte an output file recording which lines in the file cannot be processad correctly due to an improperty formatted date, and alow a user to enter in an ID number and print out that person's Information Usaful Reminders 1. Read the assignment over a few times. At least twice. I always helps to have a clear picture of the overall assignment when understanding how to build a solution 2 Think about the problem for a while, and even try writing or drawing a solution using pencil and paper or a whiteboard 3. Before submitting the assignment, review the "Functional Requirements" section and make sure you hit all the points. This will not guarantee a perfect score, however Part 0 -Prerequisites 1. Our first step will be to create a github repo for this assignment. Please call it 18211_Assignment2 2 After that is completed, use it to clone this repository to a local folder in your development environment. Al development will be in this directory Part1 - Think about Design When approaching programming problems, you should first step back and think about the problem at hand. What exactly are we trying to accomplish, and what would be a good structure for your program? How would you break the larger problem into a set of smaller steps? One thing to think about in this case, is how you will want to store this data after reading it from the CSV Part I-Download the Data Write a function called download Data which takes in a string called uit. The purpose of this function is to download the contents located at me urt and return it to the cater. You should use urilib2 for this. Do not catch any exceptions here, as this will be done tater Partill - Process Data Witte a function called processData, which takes the contents of the file as the first parameter, processes the file ina byline, and retumsa dictionary that maps a person's D to a tuple of the form (name, birthday). The birthday needs to be a Datetime object, not a string. You will have to process the birthday, which has a format of odmmyyyy, and convert it into a Datetime object (NOTE: the time portion of the Datatimo object will be 0. since we are not setting a time, just a date: you can use the Date object Instead, you feel comfortable doing so) As stated above, the birthday might not be in a correct format. This might be due to a typo in the data (.o., a missing forward slash as in 0304.2014) or an invalid dato (le 04/13/2014). If this is the case, we want bg this oror using the logging module. This function should get a logger using the namo 'assignment. This logger will be configured later in the program The log massage should be sent to the ERROR level, and of the format "Error processing line nenum> for ID #cid>, where and are the line number and ID, respectively, of the person in the CSV file that has a malformed date. Food For Thought There are many ways to represent that data in the CSV Ne using the basic Python data types. Why did we choose to store the data in the form of a dictionary that maps IDs to fupins? No need to submit this, but think about why this was chosen Feel free to post about this in the weekly discussion board Part IV - Display User Input Write a function called displayPerson, which takes in an integer called id as its first parameter, and a dictionary as its second parameter, called personData. The purpose of this function is to print the name and birthday of a given user identified by the input id if there is not entry with the given id, then print "No user found with that instead Otherwise the format should be "Person #id> is with a birthday of date where is the sid>The user requested name is the name of the person (from the file) and date is the birthday of the user formatted as YYYY-MM-DD. NOTE: there is no time being displayed) Part V. Putting it all together We now need to piece all these functions together. Lets write a main function that is called when our script 2 First your program should use the argparse module to allow the user to send a-url parameter to the script. This parameter is a string and is required by the program. If no-urf is given the program should exit Then we need to all the downloadData() function and save the results to a variable. Lets call this variable ca.Data. The URL to pass to downloadData() is the URL given as a parameter to the trict via garse Also we need to ensure that any exception is thrown by this function that we catent.print out an appropria enor message and exit the program We need to set up a logger with name assignment which should be configured to write to a ingre fit called "eron logThis can be done in a separate function of done in the main program Next we need to take care and pass the processData() function. The result of this can should be said to varat cated person Remember this is a dictionary that maps is to fupes + 5. Next, ask the user for an ID to lookup a the user enters in a negative number or 0, exit the program b. the user enters in a positive number, uso displayPerson to attempt printing out the user c Keep asking the user for input until they enter in a negative number or 0 to act Functional Requirements: In this section, we wil outline the various behaviours the program must do in order to get credit, and how we will be checking that these behaviours work correctly 1 The program must accept and use the url parameter. We will use this to point to not only the file in this assignment, but to another fie you will not be able to see beforehand. The program should give correct output in both cases 2 The program must write to a file named error dog 3. Each line of this error file must be of the correct format as specified in Part II 4. The program must print out users in the correct format, as directed by the user input 5. The program must exit only when the user enters in a number 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!