I have a csv file with the following columns:
id,name,age,sex
Followed by a lot of values for the above columns. I am trying to read the column names alone and
I am just mentioning how to get all the column names from a csv file. I am using pandas library.
First we read the file.
import pandas as pd file = pd.read_csv('details.csv')
Then, in order to just get all the column names as a list from input file use:-
columns = list(file.head(0))