
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.

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 4 images

- Code in C language. Please provide code for 3 different files. One header file and two .C files. I need the code for each file. Please provide photos of the output and source code for each file (3). Please follow All instructions in the photo provided. Use the provided input.txt file provided below. A1, A2 20294 Lorenzana Dr Woodland Hills, CA 91364 B1, B2 19831 Henshaw St Culver City, CA 94023 C1, C2 5142 Dumont Pl Azusa, CA 91112 D1, D2 20636 De Forest St Woodland Hills, CA 91364 A1, A2 20294 Lorenzana Dr Woodland Hills, CA 91364 E1, E2 4851 Poe Ave Woodland Hills, CA 91364 F1, F2 20225 Lorenzana Dr Los Angeles, CA 91111 G1, G2 20253 Lorenzana Dr Los Angeles, CA 90005 H1, H2 5241 Del Moreno Dr Los Angeles, CA 91110 I1, I2 5332 Felice Pl Stevenson Ranch, CA 94135 J1, J2 5135 Quakertown Ave Thousand Oaks, CA 91362 K1, K2 720 Eucalyptus Ave 105 Inglewood, CA 89030 L1, L2 5021 Dumont Pl Woodland Hills, CA 91364 M1, M2 4819 Quedo Pl Westlake Village, CA 91362 I1, I2 5332 Felice Pl…arrow_forwardWhat header file must be included *Match* 1. to perform a mathematical function like sqrt 2. to use random numbers 3. to use random numbers 4. to use stream manipulators like setprecision A. iostream B. cmath C. iomanip D.cstdlibarrow_forwardJupyter Notebook Python 1. Give examples to show at least two different ways to select a subset of columns from data frame data. 2. Give examples to show at least two different ways to select a subset of rows from data frame data.arrow_forward
- Write f95 code for storing values from 1 to 5, 5 times each and display them. Use appropriate storage structure accordingly.arrow_forwardI want to read the numbers from random_number.txt and then display the number and display total of the number and the number of random number read from the file and the average of this numberarrow_forwardData: 6,4,5,3,0,7 Write a program to sort data from large numbers to small numbers using the metode descendingarrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





