Question: I need to read and write data using three different data files named: data.csv data.json data.pkl Each file contains a portion of the total dataset
I need to read and write data using three different data files named:
- data.csv
- data.json
- data.pkl
Each file contains a portion of the total dataset that altogether comprises 100 records, so I need toread in all of the files and combine them into some standard formatwith which you are comfortable. Aim for something standard where each "row" is represented in the same format.Name this object that contains the data for all three files combinedfull_data
Need answers to following questions:
- What are the unique countries in the dataset, sorted alphabetically? Write to a new file called question_1.csv.
- What are the unique complete email domains in the dataset, sorted alphabetically? Write to a new file called question_2.csv.
- What are the first names of everyone (including duplicates) that do not have a P.O. Box address, sorted alphabetically? Write to a new file called question_3.csv.
- What are the full names of the first 5 people when you sort the data alphabetically by country? Write to a new file called question_4.csv.
- What are the full names of the first 5 people when you sort the data numerically ascending by phone number? Write to a new file called question_5.csv.
I need to make sure the following points while answering:
- The answers are all in onecolumnwith one list item per cell, sorted as stated in the question. I.e., looking at the .csv in a spreadsheet editor like Google Sheets, all answers would be in the 'A' column, with the first entry in A1, the second in A2, etc.
- Please do not include a header; just the answers to the questions.
- It is strongly recommended that you open each .csv file to ensure the answers are there and displayed correctly!
- Don't include quotes around the list items. I.e., strip the leading and trailing quotes, if necessary, from items when you write to the .csv files. For example, a list entry should look likeSpainrather than"Spain". One exception: Some country names do contain commas and it is ok to have quotes:""around just those country names so that they will be in one cell in the .csv.
Assumptions
- You might have to make decisions about the data. For example, what to do with ties or how to sort the phone numbers numerically.
- Please do some research before making an assumption (e.g. what is a domain name?); put your notes inside that assumption so we can understand your thought process.
- NOTE: If you don't know what an email domain is - do some research and write what you found in your assumptions; there is a correct answer to this question!
- This is a good habit as you analyze data so that you can remember why you made the decisions you did and other people can follow your analysis later!
Restrictions
You should use these standard library imports:
import json import csv import pickle
I CANNOT USE PANDAS LIBRARY FOR THIS PROBLEM
data.csv file contains following (I could not attach documents)
,Name,Phone,Address,City,Country,Email
0,Hillary Benton,1-243-669-7472,144-1225 In R..s@eudolor.edu
1,Morgan Y. Little,155-3483,Ap #909-6656 Ac S..e@quis.ca
2,Camden Z. Blair,123-5058,"P.O. Box 441, 6183 Ligula St.",Casanova Elvo,"Palestine, State o..m@ultrices.org
3,Alexandra E. Saunders,1-637-740-7614,305-496 Morbi R..e@duinecurna.org
4,Hanae P. Walsh,901-2461,7058 Dapibus S..i@tinciduntpedeac.com
5,Jescie Sargent,265-1176,421-5501 Cursus. St.,Tulsa,Holy See (Vatican City S..a@ullamcorper.co.uk
6,Kessie Morgan,945-0713,Ap #481-6631 Vehicula Rd.,Pedro Aguirre Cerda,"Bonaire, Sint Eustatius and S..t@vitaeeratVivamus.net
7,Bevis M. Santos,227-9994,"P.O. Box 575, 4033 Mi S..c@Aliquamfringilla.com
8,Flynn Alston,398-8097,"Ap #763-5990 Nec, A..r@Phasellusdapibus.edu
9,Charles F. Crawford,791-5111,Ap #841-1623 Vitae Avenue,Hindupur,South Georgia and The South Sandwich I..t@nectellusNunc.net
10,Cairo Wolfe,1-930-942-2322,9269 Libero A..e@arcuVestibulumante.org
11,Elijah Myers,1-238-336-4864,"P.O. Box 677, 2311 Aliquet. Road",Port H..s@posuereat.net
12,Thane Burch,1-894-978-3696,"7438 Amet, R..e@Namligula.edu
13,Katelyn Munoz,220-5054,"P.O. Box 432, 9085 Nulla Ave",Requnoa,Congo (..s@fermentumarcu.edu
14,Genevieve Holland,992-6968,1768 Magna. Road,Moose J..a@euultrices.co.uk
15,Wesley Z. Sharp,1-960-740-2261,"P.O. Box 497, 8354 Habitant St.",Bear,Cayman I..t@sedsapien.ca
16,Tatyana H. French,1-120-782-6047,217-9163 Lobortis R..r@magna.com
17,Meredith F. Clayton,425-7583,Ap #929-9420 Vivamus Rd.,Friedberg,Czech R..a@dui.co.uk
18,Rajah Carrillo,1-576-789-5730,910-8300 Varius R..n@cursuset.net
19,Gabriel Richmond,1-387-932-2096,7458 Sapien. S..e@anteblanditviverra.co.uk
data.json file contains following (I could not attach documents)
{"Name":{"20":"Paul Merrill","21":"Brynne S. Barr","22":"Cyrus Buckley","23":"Chloe Burnett","24":"Zachery Wilcox","25":"Casey Mcgowan","26":"Cole X. Hopper","27":"Tara Bender","28":"Malik Grimes","29":"Ulla Russo","30":"Colby Moran","31":"Maggy Wooten","32":"Cameron Guthrie","33":"Gail Villarreal","34":"Harding Salinas","35":"Idona W. Bonner","36":"Warren Castillo","37":"Clayton Harmon","38":"Alana Vasquez","39":"Mason R. Trujillo"},"Phone":{"20":"1-313-739-3854","21":"939-4818","22":"266-3123","23":"828-0406","24":"1-611-756-4723","25":"1-155-558-4461","26":"1-328-505-0545","27":"1-757-378-4079","28":"793-4359","29":"662-7778","30":"1-788-230-1991","31":"912-7242","32":"988-2217","33":"1-405-823-4207","34":"1-505-843-5401","35":"283-6921","36":"1-250-875-9104","37":"1-609-380-9257","38":"1-853-288-4269","39":"172-5777"},"Address":{"20":"916-8087 Vehicula Rd.","21":"878-2231 Suspendisse Rd.","22":"P.O. Box 572, 7680 Ullamcorper Ave","23":"563-4105 Donec Avenue","24":"462-2112 In Rd.","25":"420-7327 Facilisis Street","26":"561-7476 Eget St.","27":"1247 Nonummy Rd.","28":"Ap #603-3303 Libero. St.","29":"P.O. Box 975, 4593 Ante. Street","30":"3696 Augue Ave","31":"P.O. Box 365, 6109 Metus. Rd.","32":"Ap #861-8699 Non Ave","33":"371-7266 Tortor Avenue","34":"4167 Nunc Ave","35":"Ap #302-2966 Cum Av.","36":"Ap #275-2917 Curabitur Rd.","37":"6930 Duis Road","38":"1511 Lobortis Ave","39":"Ap #711-213 Sagittis Avenue"},"City":{"20":"Le Mans","21":"Wilhelmshaven","22":"Sangli","23":"Wabamun","24":"Barddhaman","25":"Pfungstadt","26":"Saint John","27":"Avellino","28":"Winnipeg","29":"Vit\u00f3ria da Conquista","30":"Hualp\u00e9n","31":"Kapuskasing","32":"Pontypridd","33":"Saint-Remy-Geest","34":"Arsimont","35":"Nieuwenrode","36":"La Baie","37":"College","38":"Richmond Hill","39":"Quinta Normal"},"Country":{"20":"Somalia","21":"Samoa","22":"Taiwan","23":"Morocco","24":"Hong Kong","25":"Iran","26":"Macao","27":"Dominica","28":"Congo (Brazzaville)","29":"Slovakia","30":"France","31":"Indonesia","32":"Turks and Caicos Islands","33":"Marshall Islands","34":"Montserrat","35":"Faroe Islands","36":"Ireland","37":"United S..e@suscipitest.ca","21":"euismod.et.commodo@n..m@Quisqueimperdiet.ca","23":"nec.orci.Donec@S..t@tinciduntaliquamarcu.com","25":"tellus.faucibus.leo@S..a@Lorem.net","27":"libero.Integer@l..m@consectetuercursuset.org","29":"mauris.sit.amet@b..u@Aenean.edu","31":"facilisis.eget.ipsum@c..m@liberoDonec.net","33":"Curabitur.dictum.Phasellus@m..m@velesttempor.edu","35":"elementum.lorem@c..n@ametrisus.com","37":"bibendum@i..o@egestas.net","39":"egestas@malesuadamalesuadaInteger.ca"}}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
