Question
def txt_to_csv(input_file): output file from function above cats.txt 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 American Wirehair,Mutation,Rex,All Aphrodite Giant,Natural,All,All Arabian
def txt_to_csv(input_file):
output file from function above "cats.txt"
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 American Wirehair,Mutation,Rex,All Aphrodite Giant,Natural,All,All Arabian Mau,Natural,Short,All Asian,Natural,Short,Evenly solid Asian Semi-longhair,Crossbreed between the Burmese and long-haired cats,Semi-long,Evenly solid Australian Mist,Crossbreed between the Abyssinian and Burmese,Short,Spotted or marbled Balinese,Mutation of the Siamese,Long,Colorpoint Birman,The original Birman was crossed with the Siamese and the Persian to create the Birman of today.,Semi-long,Mitted colorpoint Bombay,Crossbreed between the Black American Shorthair and Sable Burmese,Short,Solid black Brazilian Shorthair,Natural,Short,All British Longhair,Natural,Semi-long,All British Shorthair,Natural,Short,All
Dwelf,"Crossbreed between the American Curl, Munchkin and Sphynx",Hairless,All Egyptian Mau,Natural,Short,Spotted tabby European Shorthair,Natural,Short,All
Korn Ja,Natural,Short,Solid black Kurilian Bobtail orKuril Islands Bobtail,"Natural, mutation",Short/long,All Lambkin,Crossbreed between the Munchkin and Selkirk Rex,Rex,All LaPerm,Mutation,Rex,All
def michelin_guide(input_file):
Question
def michelin_guide(input_file): - Using the list of lists from question above, create a dictionary of lists where each key in the dictionary is a coat type - Only use information from EVEN lines. Skip all odd lines. - Each value should be a DISTINCT LIST of the corresponding coat patterns that a cat breed can have - Write the dictionary to a JSON file with the name passed in as output_file. - Return the dictionary of lists
Args: alist (list of lists from Q3) Returns: dictionary of lists
Output: {'All': ['All'], 'Hairless': ['All', 'Solid gray', 'Solid', 'Solid black roan'], 'Hairless, velour, brush, or straight coat': ['All'], 'Long': ['All', 'All but colorpoint', 'Ticked tabby', 'Solid white', 'Colorpoint, mitted, or bicolor', 'Solid, classic tabby, spotted tabby and ticked tabby', 'Colorpoint', 'Solid chocolate, solid lilac and solid taupe or any of these colors ' 'with white'], ... 'Short/long': ['All', 'Colorpoint'], 'Short/long (longhair, sometimes in early generations, can appear to be semi-long)': ['All']} '''
if __name__ == "__main__":
pprint(write_to_json(txt_to_csv("cats.txt"), 'cats.json'))
(Please provide the Python code and the resulting output)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started