python insert header to csv code example
Example 1: how to add header in csv file in python
#header in csv file
import pandas as pd
import csv
df = pd.read_csv("file.csv", header=None)
df.to_csv("file.csv", header=["SEQUENCE"], index=False)#header added
df = pd.read_csv("file.csv")
df
Example 2: how to add header in csv file in python
from pandas import read_csv
df = read_csv('test.csv')
df.columns = ['a', 'b']
df.to_csv('test_2.csv')