import csv with open('data.csv', 'w') as file: writer = csv.writer(file) writer.writerow(['name', 'age', 'gender']) writer.writerow(['Tom', '20', 'male']) writer.writerow(['Lucy', '18', 'female'])