Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please provide the Python code and the resulting output. Question - cats.txt contains information about cat breeds and their various characteristics. - Read the cats.txt

Please provide the Python code and the resulting output.

Question - cats.txt contains information about cat breeds and their various characteristics. - Read the cats.txt with FILE I/O. - These are TAB separated values - Use a list of lists to create a CSV file with the appropriate data WITHOUT WHITESPACE (remove \t) named "cleaned_cats.csv". - Exclude the "body_type" column - If a row has a length < 5, remove it. - For strings containing extra quotes, strip the extra quotes. - Return the list of lists.

Args: input_file (cats.txt) Returns: List of lists

Output: [['breed', 'type', 'coat_type', 'coat_pattern'], ['Abyssinian', 'Natural', 'Short', 'Ticked tabby'], ['Aegean', 'Natural', 'Semi-long', 'Multi-color'], ['American Bobtail', 'Mutation', 'Semi-long', 'All'], ['American Curl', 'Mutation', 'Semi-long', 'All'], ['American Ringtail', 'Mutation', 'Semi-long', 'All'], ['American Shorthair', 'Natural', 'Short', 'All'], ['Persian (traditional)','Natural, but some crossbreeding with the Turkish Angora','Long','All but colorpoint')], ['Ukrainian Levkoy', 'Crossbreed between the Donskoy and Scottish Fold', 'Hairless', 'Solid gray'], ['York Chocolate', 'Natural', 'Long', 'Solid chocolate, solid lilac and solid taupe or any of these colors with white']]

cats.txt

breed type body_type coat_type coat_pattern Abyssinian Natural Semi-foreign Short Ticked tabby Aegean Natural Moderate Semi-long Multi-color American Bobtail Mutation Cobby Semi-long All American Curl Mutation Semi-foreign Semi-long All American Ringtail Mutation Foreign Semi-long All American Shorthair Natural Cobby Short All

Persian (traditional) "Natural, but some crossbreeding with the Turkish Angora" Cobby Long All but colorpoint

Ukrainian Levkoy Crossbreed between the Donskoy and Scottish Fold Moderate Hairless Solid gray York Chocolate Natural Moderate Long "Solid chocolate, solid lilac and solid taupe or any of these colors with white"

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_2

Step: 3

blur-text-image_3

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 1 Lnai 6321

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215879X, 978-3642158797

More Books

Students also viewed these Databases questions

Question

What will you do or say to Anthony about this issue?

Answered: 1 week ago