hi i had this as a test yesterday and i would like to know if i did any bad mistakes , i could  not ask my classmates for their code , so can you please code this one for me please , i did it in 45 mins but i guess a proffessional will have it done in less , thank uuuu and please i want to compare my code to yours.     We have a data file that contains data in a number of rows. Each row is expected to be made of 4 items separated by a tab. We need to read the data into a python dictionary list, then do some clean up and plot the data. Write code as detailed below. Your code must follows the specs and restrictions shown below to be valid. 1. In the main function: ask the user for a file name. pass the filename to a function named fileToDict that will return a list of dictionary items. The dictionary received above will be passed to another function cleanUp which returns a cleaned up version of the data. The list received will then be passed to another function named myPlot to create a two-line plot. That function returns the plot to the main function. show the plot then ask the user if they wish to save it, and if so, ask for the filename and save the plot, else we're done. 2. The function to read the data, which should be named fileToDict will receive a file name then reads the data from the file one line at a time. For the sake of this function you are only allowed to import the regular expression module we learned about. No other import is allowed. Using a regex expression, collect the email address, this will be the key. We expect the rest of the data on that line to be a number.   If the email is unique, create an entry in the list being created, where the email is the key and the list that follows contain the number we just read from that line. Otherwise, add the number of the current line to the existing value list. For example, if email 'abc' appears in the file twice with numbers 24 and later with 56, the dictionary entry should be 'abc':['24' , '56'] Once all lines have been processed, return the dictionary. If an entry has an invalid email address, then create a key 'invalid@email.com' and add all the numeric entries of the invalid emails to that entry. If an entry has no valid numbers, then use the value 'invalid' as the numeric entry. for example if email 'abc has no valid numeric entry first then later has a valid entry of 7, then it appears as 'abc':['invalid' , '7'] 3. The function cleanUp which receives the dictionary discussed above, will create a new dictionary and returns it as follows: The new dictionary entry will be the same as the received entry if the email and the data list do not contain any entry of 'invalid'. If the email is invalid, then keep that key as is. If any of the data in the list is invalid, change it to '0'. Once the data of the current entry is processed, add all the entries and add the email as the key and the sum as the value. return the dictionary of emails and sums. This is the cleaned data. 4.  Once obtains the clean data from the function of the step above , the data will be passed to myPlot which creates a plot as follows: Using matplotlib or pandas plot the data in bars. the x axis is represented by the email addresses, with the tics showing those emails. the y axis is the value of that email. return the plot figure.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

hi i had this as a test yesterday and i would like to know if i did any bad mistakes , i could  not ask my classmates for their code , so can you please code this one for me please , i did it in 45 mins but i guess a proffessional will have it done in less , thank uuuu and please i want to compare my code to yours.

 

 

We have a data file that contains data in a number of rows. Each row is expected to be made of 4 items separated by a tab.

We need to read the data into a python dictionary list, then do some clean up and plot the data. Write code as detailed below.

Your code must follows the specs and restrictions shown below to be valid.

1. In the main function:

  • ask the user for a file name.
  • pass the filename to a function named fileToDict that will return a list of dictionary items.
  • The dictionary received above will be passed to another function cleanUp which returns a cleaned up version of the data.
  • The list received will then be passed to another function named myPlot to create a two-line plot. That function returns the plot to the main function.
  • show the plot then ask the user if they wish to save it, and if so, ask for the filename and save the plot, else we're done.

2. The function to read the data, which should be named fileToDict will receive a file name then reads the data from the file one line at a time.

  • For the sake of this function you are only allowed to import the regular expression module we learned about. No other import is allowed.
  • Using a regex expression, collect the email address, this will be the key. We expect the rest of the data on that line to be a number.  
  • If the email is unique, create an entry in the list being created, where the email is the key and the list that follows contain the number we just read from that line.
  • Otherwise, add the number of the current line to the existing value list. For example, if email 'abc' appears in the file twice with numbers 24 and later with 56, the dictionary entry should be 'abc':['24' , '56']
  • Once all lines have been processed, return the dictionary.
  • If an entry has an invalid email address, then create a key 'invalid@email.com' and add all the numeric entries of the invalid emails to that entry.
  • If an entry has no valid numbers, then use the value 'invalid' as the numeric entry. for example if email 'abc has no valid numeric entry first then later has a valid entry of 7, then it appears as 'abc':['invalid' , '7']

3. The function cleanUp which receives the dictionary discussed above, will create a new dictionary and returns it as follows:

  • The new dictionary entry will be the same as the received entry if the email and the data list do not contain any entry of 'invalid'.
  • If the email is invalid, then keep that key as is.
  • If any of the data in the list is invalid, change it to '0'.
  • Once the data of the current entry is processed, add all the entries and add the email as the key and the sum as the value.
  • return the dictionary of emails and sums. This is the cleaned data.

4.  Once obtains the clean data from the function of the step above , the data will be passed to myPlot which creates a plot as follows:

  • Using matplotlib or pandas plot the data in bars.
  • the x axis is represented by the email addresses, with the tics showing those emails.
  • the y axis is the value of that email.
  • return the plot figure.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY