So I have a text file that looks something like this:
Monstera Deliciosa
2018-11-03 18:21:26
Tropical/sub-Tropical plant
Leathery leaves, mid to dark green
Moist and well-draining soil
Semi-shade/full shade light requirements
Water only when top 2 inches of soil is dry
Intolerant to root rot
Propagate by cuttings in water
Strelitzia Nicolai (White Birds of Paradise)
2018-11-05 10:12:15
Semi-shade, full sun
Dark green leathery leaves
Like lots of water,but soil cannot be water-logged
Like to be root bound in pot
Alocasia Macrorrhizos
2019-01-03 15:29:10
Tropical asia
Moist and well-draining soil
Leaves and stem toxic upon ingestion
Semi-shade, full sun
Like lots of water, less susceptible to root rot
Susceptible to spider mites
I want to create a dictionary out of this file with the names of the plants to be the key of the dictionary and the rest of the info be put in a list as the values. So far I've managed to get each plant and its respective info as an item in a list but i'm not sure how to transform it to a dictionary.
with open('myplants.txt', 'r') as f:
contents = f.read()
contents = contents.rstrip().split('\n\n')
contents = [x.replace('\n', ', ') for x in contents]
print(contents)#[0].split(',',0)[0])
Expected output:
plants = {'Monstera Deliciosa':['2018-11-03 18:21:26', 'Tropical/sub-Tropical plant', 'Leathery leaves, mid to dark green', 'Moist and well-draining soil', 'Semi-shade/full shade light requirements', 'Water only when top 2 inches of soil is dry', 'Intolerant to root rot', 'Propagate by cuttings in water'], 'Strelitzia Nicolai (White Birds of Paradise)': ... }
I am open to better formats on how the dictionary should look like.