I have a CSV in a below format:
Expected:
Where I want to convert this to dictionary like this:
{'Masterfolder': ['Training'], 'Childfolder': ['Training videos', 'Training documents', 'Training workouts', 'Training practicals']}
So far I have done the following code,
import csv
with open('features.csv', mode='r') as f:
reader = csv.reader(f)
checker = lambda i: bool(i and i.strip())
mydict = {rows[0]: list(filter(checker, rows[0:])) for rows in reader}
print(mydict)
And my output is something like this:
{'Master folder': ['Child - 1', 'Child - 2', 'Child - 3', 'Child - 4'], 'Training': ['Training videos', 'Training documents', 'Training workouts', 'Training practicals']}
How can I improve this code to get in order to get the result as I am expecting?