I have a use case wherein I want to insert data from a list to an existing CSV file, but in the first row of the file. This should push all the other rows from the file to the next ones. Here is what I have attempted so far (which appends the list data at the bottom of the CSV file):
import csv
data = [1,2,3,4,5]
with open("data.csv", "a") as fp:
wr = csv.writer(fp, dialect='excel')
wr.writerow(data)
How can I add the data of the given list in the first row of my CSV file using Python?