[Tutor] writing csv files

prasad rao prasadaraon50 at gmail.com
Sat May 22 09:46:03 CEST 2010


hello!

I got a problem writing csv file.

1)
  csvw=csv.writer(open('/home/prasad/kkm','w'),
dialect='excel',fieldnames=names)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'fieldnames' is an invalid keyword argument for this function

2)
 for x in csvr:
...    y=lambda x: ''.join([x.split()[3],x.split()[-3],x.split()[-6]])
...    csvw.write(y)
...
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
AttributeError: '_csv.writer' object has no attribute 'write'

At  http://www.python.org/dev/peps/pep-0305/  they are using  the function write
 and the argument fieldnames.

Where is the problem?Please someone show me  a way to do it.

Prasad


More information about the Tutor mailing list