I have one csv file with thousands of rows , below is example. What I need to do is :
- Iterate over the pandas df
- create separate file for every department with list of staff(groupby or .loc)
- To name the file : If manager is found then name the file with his name if no manager , then look for officer if no manager or officer , then write a comment in the last column the file should be named as this( IT-name2.csv) as name2 staff is manager in the below picture/example.
So I have two variables , dept. name and staffname
I was able to do this but there is lots of manual work , it should not be the case. I name every csv file myself , I have 100s of lines and I add the managername in the csv filename myself , which caused some errors and it could be changed in the future
Now , for every department I have groupby line, and line to save the csv file (manually enter the managername in the filename)
How this can be more automated ?
Many thanks
.

locand then write to csv. Send theRoletolist(). If you give more details I can code it up.