i need it to print like how a 'pretty print' would print my outputs. I CANNOT USE the pretty print command. - Using for loops or loops in general is how i need to get the answer

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

hey i need help fixing my python code. I have to create a dictionary out of csv file list. 

-  i need it to print like how a 'pretty print' would print my outputs. I CANNOT USE the pretty print command.

- Using for loops or loops in general is how i need to get the answer

-this is how it SHOULD print: (see image attached with white background)

 

 

 

THIS IS MY CODE:

import csv

def book_list(dataset: str) -> dict[str,str]:

   list_of_books = list()

   book_data = csv.reader(open('Google_Books_Dataset.csv','r'))
   
   
   for row in book_data:
       list_of_books.append(row)
       
   header = list_of_books[0]
   dataset = []
   
   for i in list_of_books[1:]:
       dict = {}
       
       for j in range (len(i)):
           header[0] = header[0][3:] 
           dict.update({header[j] : i[j]})     
           dataset.append(dict)
  
   
   return dataset

 

 

--- it SHOULDN'T print like this (see image attached with black background)

= [{"title": "Antiques Roadkill: A Trash 'n' Treasures Mystery",
"authors":
Barbara Allan",
"language ": "English",
"rating": 3.3,
"publisher":
"category": "
"pageCount": 288},
{"title": "The Nightshift Before Christmas: Festive hospital
Kensington Publishing Corp.",
Fiction",
diaries from the author of million-copy hit",
"authors": " Adam Kay",
"language": "English",
"rating": 4.7,
"publisher": "Pan Macmillan",
"category": " Biography ",
"pageCount": 112,
},
{another element},
...
Transcribed Image Text:= [{"title": "Antiques Roadkill: A Trash 'n' Treasures Mystery", "authors": Barbara Allan", "language ": "English", "rating": 3.3, "publisher": "category": " "pageCount": 288}, {"title": "The Nightshift Before Christmas: Festive hospital Kensington Publishing Corp.", Fiction", diaries from the author of million-copy hit", "authors": " Adam Kay", "language": "English", "rating": 4.7, "publisher": "Pan Macmillan", "category": " Biography ", "pageCount": 112, }, {another element}, ...
[{'': '1', 'title': "Antiques Roadkill: A Trash 'n' Treasures Mystery", 'author': 'Barbara Allan',
on', 'language': 'English'}, {'': '31', 'title': 'No Mercy: The brand new novel from the Queen of (
Martin', 'rating': '4.5', 'publisher': 'HarperCollins UK', 'page_count': '864', 'generes': 'Fantas)
'89',
'title': 'The Mysterious Affair at Styles', 'author': 'Agatha Christie', 'rating': '4.4', 'pu
: '5', 'publisher': 'Simon and Schuster', 'page_count': '224', ' generes': 'Economics', 'language':
1', 'author': 'Art Baltazar', 'rating': '4.1', 'publisher': 'DC', 'page_count': '164', 'generes':
'English'}, {'': '176', 'title': 'The Secrets of Saving and Investing with Alvin Hall: Simple Strat
|>>|
Transcribed Image Text:[{'': '1', 'title': "Antiques Roadkill: A Trash 'n' Treasures Mystery", 'author': 'Barbara Allan', on', 'language': 'English'}, {'': '31', 'title': 'No Mercy: The brand new novel from the Queen of ( Martin', 'rating': '4.5', 'publisher': 'HarperCollins UK', 'page_count': '864', 'generes': 'Fantas) '89', 'title': 'The Mysterious Affair at Styles', 'author': 'Agatha Christie', 'rating': '4.4', 'pu : '5', 'publisher': 'Simon and Schuster', 'page_count': '224', ' generes': 'Economics', 'language': 1', 'author': 'Art Baltazar', 'rating': '4.1', 'publisher': 'DC', 'page_count': '164', 'generes': 'English'}, {'': '176', 'title': 'The Secrets of Saving and Investing with Alvin Hall: Simple Strat |>>|
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Basics of loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education