Arun Tomar wrote:
hi!

I've a list

new_array = ['n1', 'm1', 'p1', 'n2', 'm2', 'p2', 'n3', 'm3', 'p3']

I am trying to convert this to a csv in 3 columns so that the final
output would look something like this

"n1","m1","p1"
"n2","m2","p2"
"n3","m3","p3"

This can easily be done with the "csv" module in the Python standard library. Just create a csv.writer object, and call the writerow() method in it for every three elements in new_array and you're done.

regds,
arun.



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to