Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to append the contents of csv files by python

Shulou Source: shulou.com Published: 2022-05-31 11:13:05 09月23日 Update

This article mainly introduces python how to add csv file content related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you read this python how to append csv file content article will have a harvest, let's take a look at it.

The specific steps are as follows:

1. First, open python and create a new python project

After the 2.python project is created, import the csv library in the project using the import method

Import csv

After the 3.csv library is imported, use the open () function to open the csv file and call the

File = open ("test.csv") reader = csv.reader (file)

After the 4.csv file is opened, you can use the content.writerow () method to append content to the csv file

Original = list (reader) file1 = open ("test1.csv", "w", newline= "") content = csv.writer (file1) for row in original:content.writerow (row) content.writerow (["1", "Zhang San", "male"]) file.close () file1.close () this is the end of the article on "how python appends the contents of csv files". Thank you for reading! I believe you all have a certain understanding of "how to add the contents of csv documents in python". If you want to learn more, you are welcome to follow the industry information channel.

Tags: Content documents knowledge projects methods articles values functions easy to operate articles easy to understand more steps look industry information channels channels Zhang San build Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Shulou Tech Info OPPO Reno Apple Redmi