Categories
Python Answers

How to append new row to old csv file with Python?

Spread the love

Sometimes, we want to append new row to old csv file with Python.

In this article, we’ll look at how to append new row to old csv file with Python.

How to append new row to old csv file with Python?

To append new row to old csv file with Python, we can open the file with append permission and then use the write method to append the new row.

For instance, we write

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

to open the document.csv file with 'a' permission to let us append to the file.

Then we call write with the csv_row string to write the row to the csv file.

Conclusion

To append new row to old csv file with Python, we can open the file with append permission and then use the write method to append the new row.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *