import csv
with open('file.csv', 'r') as file:
    csv_reader = csv.DictReader(file)
    with open('new_file.csv','w') as new_file:
        fieldnames = ['timestamp','src-user','dst-user']
        csv_writer = csv.DictWriter(new_file, fieldnames=fieldnames, delimiter='\t')
        csv_writer.writeheader()
        for line in csv_reader:
            csv_writer.writerow(line)
I wrote this code to create new csv file from old one with appending to it when i tried to write it as dictionary it shows me this error ValueError: dict contains fields not in fieldnames: 'timestamp'
 
    