read header of csv file python

Solutions on MaxInterview for read header of csv file python by the best coders in the world

showing results for - "read header of csv file python"
Torin
17 Jan 2016
1import csv    
2
3with open(fpath, 'r') as infile:
4    reader = csv.DictReader(infile)
5    fieldnames = reader.fieldnames
6
Madisyn
30 Jun 2019
1In [27]: df 
2Out[27]: 
3          A         B         C
40 -0.166919  0.979728 -0.632955
51 -0.297953 -0.912674 -1.365463
62 -0.120211 -0.540679 -0.680481
7In [28]: df.columns
8Out[28]: Index (['A', 'B', 'C'], dtype='object')
9