1import csv
2
3f = open("fruits.csv", "w")
4writer = csv.DictWriter(
5 f, fieldnames=["fruit", "count"])
6writer.writeheader()
7f.close()
8Outputfruits.csvfruit,count
9
1#header in csv file
2import pandas as pd
3import csv
4df = pd.read_csv("file.csv", header=None)
5df.to_csv("file.csv", header=["SEQUENCE"], index=False)#header added
6df = pd.read_csv("file.csv")
7df
1 from pandas import read_csv
2
3 df = read_csv('test.csv')
4 df.columns = ['a', 'b']
5 df.to_csv('test_2.csv')
6