[Solved]Question 6 7 Marks Given Csv File Following Format Location Write Function Loads Data Csv Q37248283
Python
Question 6. (7 marks) You are given a CSV file of the following format: <product name>, <amount>,location> Write a function that loads the data in the CSV file into a dictionary with the following format: <product _name> [amount>, location>], [<amount?, <location>I For example, the CSV file on the left should be transformed to the dictio on the ri Dict CSV ‘widget’: [[230, Toronto’], [200, Vancouver]] bucket: [[200, Toronto]] ‘gadget’: [[113, ‘Montreal’]]) widget,230,Toronto gadget, 113,Montreal bucket,200,Toronto widget,200,Vancouver A product may occur multiple times in the CSV file if it is located in multiple locations. But for any pair of product and location, there will be at most one entry in the CSV file (e.g., you will not have two entries for widgets in Toronto) Write the function load inventory which creates and fills the dictionary as defined above. The function should read the CSV file, create and fill the dictionary, and return the dictionary You can esiewil be opened success can assume that: the file will be opened successfully the CSV file contains no spaces between entries import csv def load inventory(filename) ‘ (str) -> dictionary str[int, str, [int, str], .. .1) Input: a string specifying the CSv filename Output a dictionary representing the inventory, amounts, and locations. Start here and continue on the next page. Show transcribed image text Question 6. (7 marks) You are given a CSV file of the following format: , ,location> Write a function that loads the data in the CSV file into a dictionary with the following format: [amount>, location>], [ dictionary str[int, str, [int, str], .. .1) Input: a string specifying the CSv filename Output a dictionary representing the inventory, amounts, and locations. Start here and continue on the next page.
Expert Answer
Answer to Question 6. (7 marks) You are given a CSV file of the following format: , ,location> Write a function that loads the dat… . . .
OR

