I am trying to learn python and a beginner. I have a tab delimited text file and I would like to extract 2nd column of the file using the header name of the 2nd column. This is my dummy file:
col1 col2 col3 col4
a 1 2 3
d 4 5 0
f 3 2 1
I have done something like this:
f = open('test.txt',"r")
header = f.readline()
header = firstline.rstrip("\n").split("\t")
for row in f:
row = row.rstrip("\n")
# i cannot figure out what should I do next
I want the output to be
col2
1
4
3