I have the following code which is reading a list of folders from a directory, and dumping them into a csv file.
import os, csv
mylist = os.listdir("M:/")
with open("output.csv", 'w') as myfile:
wr = csv.writer(myfile, lineterminator='\n')
wr.writerows(([row] for row in mylist))
Which is working well. The folders in the directory are all named using this format:
abc_123456
And the output I'm trying to get is:
abc, 123456
def, 789012
etc.
I know that I need to use split() but I can't work out where it needs to go