Question: def csv_cleaner(input_file): ''' Question - Read michelin.csv with CSV module and return a list of lists containing each cleaned row. - Make sure to include

def csv_cleaner(input_file): ''' Question - Read michelin.csv with CSV module and return a list of lists containing each cleaned row. - Make sure to include the headers - There are 3 issues with the csv that must be fixed: 1. Combine the last 2 columns to make one column. Rename this to be 'Cuisine Type' 2. Remove any excess white space from the new column, 'Cuisine Type', as well as the column titled 'Country' 3. Fill in all empty spaces in the 'Price' column with the average (as an integer) of the total price in an equivalent string format - 1 is equivalent to $ - 2 is equivalent to $$ - 3 is equivalent to $$$ and so on - Average is equal to the total dollar signs / total number of rows - Write the list of lists to a new csv file called 'clean_michelin.csv' to use for Question - Make sure to write to the new csv file before the return statement

Args: input_file(michelin.csv) Returns: Nested list

Expected Output: [['', 'Unnamed: 0', 'Restaurant Name', 'Number of Stars', 'City', 'Country', 'Price', 'Cuisine Type'], ... ['3', '3', 'Bottiglieria 1881', '1', 'Cracow', 'Poland', '$$$', 'Creative']]

'''

michelin.csv

,Unnamed: 0,Restaurant Name,Number of Stars,City,Country,Price,Cuisine_type_1,Cuisine_type_1.1 0,0,essncia,1,Budapest, Hungary,$$$,, Modern Cuisine 1,1,Babel,1,Budapest, Hungary,$$$$,Modern Cuisine, 2,2,Borkonyha Winekitchen,1,Budapest, Hungary,$$,Modern Cuisine, 3,3,Bottiglieria 1881,1,Cracow, Poland,$$$,Creative,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!