I have a list of list of lists that I need to write to a csv file.
mylist = [['Siddharth','Bangalore','[email protected]'],
['Rahul','Bangalore','[email protected]'],.....and so on]
This list is usually some 20,000 to 40,000 long.
So, right now, the only way to write them to a csv file is to iterate over the list and write:
fileObj = open("/home/siddharth/sample.csv", "wb")
csv_file = csv.writer(fileObj)
for item in mylist:
csv_file.writerow(item)
So, I just to wanted to know, is there a way to write such a list of lists to csv, without iterating over each item in the list, eg. like using StringIO etc.
Or, can anyone give some tip/hint, so that I can create my own implementation.
python -mcProfile your_script.pyto find out which functions take the most time.