to write set of values to a file from python

muttu2244 at muttu2244 at
Thu Dec 15 00:39:02 CET 2005

thanks lawrence
it did work.
and i have one more question for you

its printing the feilds name in the following way


that means each row its printing one field name, can i make it to print
each one of the field in different columns, in this way

CompName                   IpAddr                  MacAddr

and then to fill up the values for these fields , something like this

CompName               IpAddr                   MacAddr


thanks again

Lawrence Oluyede wrote:
> Il 2005-12-14, muttu2244 at <muttu2244 at> 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 -
> "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