to write set of values to a file from python

muttu2244 at yahoo.com muttu2244 at yahoo.com
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

CompName
IpAddr
MacAddr

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
XXX                       192.178.23.11            78.23.34.23.12
YYY                      192.189.22.11           89.23.43.12.34
ZZZ                        192.179.24.45           89.23.34.12.45

etc.

thanks again
yogi


Lawrence Oluyede wrote:
> 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