# (A) LOAD CSV MODULE import csv # (B) READ EXISTING ROWS INTO A LIST with open("demo.csv", "r", newline="") as csvfile: rows = list(csv.reader(csvfile)) # (C) PREPEND NEW ROWS rows = [["G", "H"], ["I", "J"]] + rows # (D) SAVE UPDATED CSV with open("demo.csv", "w", newline="") as csvfile: writer = csv.writer(csvfile) writer.writerows(rows)