List to CSV in Python

Posted by Steve on Stack Overflow See other posts from Stack Overflow or by Steve
Published on 2010-04-19T11:11:37Z Indexed on 2010/04/19 11:13 UTC
Read the original article Hit count: 429

Filed under:
|

Hi, I am creating a CSV from a list of values. CSV File gets created but the csv is formed as a single column. Actually it should be multiple rows with multiple columns, instead it forms as a multiple rows with a single column. I am using the following code

from random import choice import csv fileObject = csv.writer(open('Insurance.csv','w'),dialect='excel',delimiter=' ') for i in range(0,175): current_list = list(choice(master_list)) fileObject.writerows(current_list) current_list = []

Thanks

© Stack Overflow or respective owner

Related posts about python

Related posts about csv