using the csv
module from the standard library and the open method to avoid leaving the file open.
The key point is using 'a'
for appending when you open the file.
import csv
fields=['first','second','third']
with open(r'name', 'a') as f:
writer = csv.writer(f)
writer.writerow(fields)
You may experience superfluous new lines in Windows. You can try to avoid them using 'ab'
instead of 'a'. CSV is a binary format, believe it or not.
http://stackoverflow.com/questions/2363731/append-new-row-to-old-csv-file-python http://stackoverflow.com/questions/4249185/using-python-to-append-csv-files