to write set of values to a file from python

Lawrence Oluyede raims at dot.com
Wed Dec 14 17:36:00 EST 2005


Il 2005-12-14, muttu2244 at yahoo.com <muttu2244 at yahoo.com> ha scritto:
> I have tried with the following code
>
> import csv
> file = open("some.csv","wb")
> writer = csv.writer(file)
> list = ["CompName", "IpAddr", "MacAddr","OpSys"]
> for row in list:
>     writer.writerow(row)
>
> file.close()

writerow() wants a sequence, a string is a sequence of chars and hence
it writes a char at time, replace with

writer.writerow([row])



-- 
Lawrence - http://www.oluyede.org/blog
"Anyone can freely use whatever he wants but the light at the end
of the tunnel for most of his problems is Python"



More information about the Python-list mailing list