add new csv line

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Mar 19 19:52:14 EDT 2008


En Wed, 19 Mar 2008 13:01:08 -0300, Alexandru Dumitrescu  
<alexandru.dumitrescu at gmail.com> escribió:

> Is there a way to add a new line at the beginning of  a  *.csv file,
> line which contain the name of the columns?

Once the file was written? You have to create another file, write the  
headings, and copy the data from the first one.

If you are asking how to do that with a csv.Writer object, just call  
writerow(list_of_column_names) before writing the data itself.

-- 
Gabriel Genellina




More information about the Python-list mailing list