How to print out a hierarchy tree of the employees
<p>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.</p>

<p>Sample input from csv file</p>

<pre><code>Sam, Ian, technical lead, 2009 / Ian, NULL, CEO,2007/ Fred, Sam,developer, 2010
</code></pre>

<p>The format is name, supervisor, designation, year of joining.</p>

<p>The output should be</p>

<pre><code>Ian CEO 2007

-Sam Technical lead 2009

--Fred Developer 2010
</code></pre>

<p>I am not sure but I have tried it as below. Please suggest changes to this code or any other solutions you have.</p>

<pre><code>strq = "Sam, Ian, technical lead, 2009 / Ian, NULL, CEO,2007/Fred, Sam, developer, 2010"
def treeEmployee(infoStr):
    str1 = infoStr.split("/")
    s2 = []
    for i in str1:
        s2.append(i.split(","))
    for i in range(len(s2)):
        for j in range(1, len(s2)):
            if s2[i][1] == s2[j][0]:
                s2[i], s2[j] = s2[j], s2[i]
            return s2

print treeEmployee(strq)
</code></pre>

<p>I want the output to be </p>

<pre><code>Ian CEO 2007

-Sam Technical lead 2009

--Fred Developer 2010
</code></pre>