I have a csv file like below. The ID is the unique identifier of each employee, and the MANAGERID is the ID of his/her manager.
id,managerid,firstname,lastname,dob,address
1,0,John,A,1976-01-01,some where
108,12,Tom,B,1996-01-01,some where
85,12,Jerry,C,1975-01-01,some where
12,1,Winsor,D,1984-01-01,some where
16,85,Smith,H,1977-01-01,some where
100,0,Ray,G,1999-01-01,some where
22,100,Albert,B,1980-01-01,some where
17,22,Robert,J,1980-01-01,some where
21,22,Linda,K,1981-01-01,some where
35,17,Lily,J,1968-01-01,some where
101,0,Sam,A,1995-01-01,some where
105,101,Liz,Z,1988-08-08,earth
I want to use a bash command/script to print out the structure, like a tree. The top manager is the root, following by the department manager and the employees of the department. The ID & name of the top manager should also be listed aside the employees.
I dont have a clue how to do this yet.
The expected output should be like this.
1:John A(1:John A)
+12:Winsor D(1:John A)
+-85:Jerry C(1:John A)
+--16:Smith H(1:John A)
+-108:Tom B(1:John A)
100:Ray G(100:Ray G)
+22:Albert B(100:Ray G)
+-21:Linda K(100:Ray G)
+-17:Robert J(100:Ray G)
+--35:Lily J(100:Ray G)
101:Sam A(101:Sam A)
+105:Liz Z(101:Sam A)
Any help would be much appreciated!