Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Append a .csv file?
#1
Hello.
Is there a way to append a .csv file? Everything I've tried writes over the existing data in a .csv file with new data. Isn't there code in python 3.6 to append a .csv file like you would a .txt file?
Pete
Reply
#2
https://docs.python.org/3/library/functions.html#open
Open the file in Append (a) mode, instead of Write (w) mode:
with open('myfile.csv', 'a') as the_file:
    print("spam,foo,bar,test", file=the_file)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to append integers from file to list? Milan 8 1,447 Mar-11-2023, 10:59 PM
Last Post: DeaD_EyE
  read a text file, find all integers, append to list oldtrafford 12 3,535 Aug-11-2022, 08:23 AM
Last Post: Pedroski55
  How to modify python script to append data on file using sql server 2019? ahmedbarbary 1 1,218 Aug-03-2022, 06:03 AM
Last Post: Pedroski55
  How to append a tuple full of records to a dbf file in Python? DarkCoder2020 4 3,727 May-29-2020, 02:40 PM
Last Post: DarkCoder2020
  Append JSON's and write to file faqsap 4 2,876 May-15-2020, 04:20 PM
Last Post: faqsap
  Cant Append a word in a line to a list err "str obj has no attribute append Sutsro 2 2,575 Apr-22-2020, 01:01 PM
Last Post: deanhystad
  Copy and append data from .dat file Makada 17 8,065 Jan-20-2020, 08:33 PM
Last Post: Makada
  txt-file: read and append missing data sufi 1 3,193 Dec-07-2019, 08:12 AM
Last Post: Gribouillis
  append my results to a file clarablanes 9 5,393 Nov-23-2018, 10:38 PM
Last Post: clarablanes

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020