Given a list of employees and their bosses as a csv file , write a function that will print out a hierarchy tree of the employees.
Sample input = Sam, Ian, technical lead, 2009 / Ian, NULL, CEO,2007/ Fred, Sam, developer, 2010
The format is name, supervisor, designation, year of joining
The output should be
Ian CEO 2007
-Sam Technical lead 2009
--Fred Developer 2010
What I have tried:
import csv
with open("list.csv", 'r') as csv_file:
list_reader = csv.reader(csv_file, delimiter=",")
employee_list = {
name: boss.strip() for name, boss, designation, year in list_reader}
mgrs = [k for k, v in employee_list.items() if v == '']
while mgrs:
print ", ".join(mgrs)
mgrs = [k for k, v in employee_list.items() if v in mgrs]
name: boss.strip() for name, boss, designation, year in list_reader}
ValueError: too many values to unpack