The only possible reason for duplicate columns that I can think of is that you already have empty 'Purchase Order Number' and 'Purchases Transaction ID Number' columns in your input file. Because you said you want to ADD my understanding was you need to add the column headers to one already in input file. That is lines#3-#4. If this is the case, try:
with open(in_file, 'r') as in_f, open(out_file, 'w', newline='') as out_f: rdr = csv.DictReader(in_f) wrtr = csv.DictWriter(out_f, fieldnames=rdr.fieldnames) wrtr.writeheader() for row_id, row in enumerate(rdr, start=1): row['Purchase Order Number'] = row_id + 60000 row['Purchases Transaction ID Number'] = row_id + 700000 wrtr.writerow(row)