python csv read header only

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

showing results for - "python csv read header only"
Fred
17 Nov 2020
1import csv    
2
3with open(fpath, 'r') as infile:
4    reader = csv.DictReader(infile)
5    fieldnames = reader.fieldnames
6
Gabriele
29 Mar 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