Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with this question along with the output In this assignment you are to write a Python program to read a CSV file consisting

Need help with this question along with the output

image text in transcribed
In this assignment you are to write a Python program to read a CSV file consisting of U.S. state information, then create and process the data in JSON format. Specific steps: 1. Read a CSV file of US state information, then create a dictionary with state abbreviation as key and the associated value as a list: {abbrev. [state name, capital, population]). For example, the entry in the dictionary for Virginia would be : {'VA': ['Virginia', 'Richmond', '7078515']}. 2. Create a JSON formatted file using that dictionary. Name the file 'state_json.json'. 3. Visually inspect the file to ensure it's in JSON format. 4. Read the JSON file into your program and create a dictionary. 5. Search the dictionary to display the list of all state names whose population is greater than 5,000,000. Notes: The input file of U.S. state information will be provided with the assignment In processing that data you'll need to read each line using READLINE, or all into one list with READLINES Since the data is comma-separated you'll have to use the string 'split' method to separate the attributes (or fields) from each line and store each in a list. Remember that all the input data will arrive in your program as a character string. To process the population data you'll have to convert it to integer format. The input fields have some extraneous spaces that will have to be removed using the string 'strip' method. As each line is read and split, add an entry for it to the dictionary as described above. . Be sure to import 'json' and use the 'dumps' method to create the output string for writing to the file. The visual inspection is for your benefit and won't be reviewed or graded. . Use the 'loads' method to process the read json file data into a Python data structure. Iterate through the dictionary and compare each state's population to determine which to display. Be sure you've stored the population in the dictionary as an integer so you can do the comparison with 5,000,000

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

1. What is socialization?

Answered: 1 week ago

Question

1. State how schools help in socialization?

Answered: 1 week ago

Question

What are the major medium of communication ?

Answered: 1 week ago

Question

Family basic steps to socialization write a short note ?

Answered: 1 week ago