[SOLVED][python] insert a row to a csv file
I have list, and would like to insert it as the last row, in a csv file.
Quote:
w=csv.writer(open('mycsvfile','a'),dialect='excel' )
w.writerows(mylist)
and getting the following error,
Quote:
_csv.Error: Sequence expected,
apparently my csv is destroyed by csv.write:( !
Re: insert a row to a csv file
Quote:
Originally Posted by
naarkhoo
I have list, and would like to insert it as the last row, in a csv file.
and getting the following error,
apparently my csv is destroyed by csv.write:( !
I don't know the rest of this interface, but when I tried it out just now, I drew the conclusion that writerows wants a list of lists, not one single list, which is logical considering the word "rows", not "row".
It may be useful to state that the language is python, also.
Re: insert a row to a csv file
Quote:
Originally Posted by
Arndt
I don't know the rest of this interface, but when I tried it out just now, I drew the conclusion that writerows wants a list of lists, not one single list, which is logical considering the word "rows", not "row".
It may be useful to state that the language is python, also.
That's why we should support this also Programming Talk Suggestion
Re: insert a row to a csv file
http://docs.python.org/library/csv.html#writer-objects
The argument to writerows() must be a list, but it can be a list of a lot of things.