import csv
file = open('D:\student.csv') # Path of CSV data file, use your path
csvreader = csv.reader(file)
l1 = []
l1 = next(csvreader) # column headers as first row
r_set = [row for row in csvreader]
Read , add changes and then write to file
path='D:/my_dir1/plus2net/python/list.php' # path of file to update
fob=open(path,'r') # Open in read mode
data=fob.read() # collect data
fob.close() # close file object
#print(data)
data=data.replace('\n\n','\n') # replace double line break with single
#print(data)
with open(path, "w") as f: # Open in Write mode
f.write(data) # rewrite data