Python modifies the header of csv files in batches

how Python3 batch modifies the header of csv files

the novice crawler crawled the data into the csv file, but later, if you want to update header
header, everything under the header is appended mode. Only header does not append
, but if you update the header field in append mode, you will append the updated header field to the end

.

this is crawled data. I want to update the header field in batch, but it cannot be repeated. The content can be repeated
. For example, I want to add a source field at the end. Is there a way to update only the header part of
python?

Apr.30,2021

reference file replacement: https://www.cnblogs.com/bigbe.
read into memory, change the first line, then write to the new file, and finally use os.system to move the file



import pandas as pd
file_path = 'heihe.csv'

df=pd.read_csv(file_path, header=0)
df.columns=["a","b","c","d","e","f"]
df.to_csv(file_path, index=False)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4537e-430c9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4537e-430c9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?