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

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.