append new row to old csv file python


I am trying to add a new row to my old csv file. Basically, it gets updated each time I run the Python script.

Right now I am storing the old csv rows values in a list and then deleting the csv file and creating it again with the new list value.

Wanted to know are there any better ways of doing this.

10/6/2015 1:22:52 PM

with open('document.csv','a') as fd:

Opening a file with the 'a' parameter allows you to append to the end of the file instead of simply overwriting the existing content. Try that.

8/14/2018 1:23:20 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow