I am trying to read a single column in my csv data file with the following function, however when I run the function it only prints out the header instead of the whole column.
I want the function to print out a single column from my csv file (including the heading) in the form of a list.
I am very confused about where I am going wrong and would be very appreciative for any help.
thank you in advance for your response.
def read_column(filename, column:int):
file = open ('data1.csv', 'r')
for rows in csv_file:
column = (rows.split(',')[0])
return column
printsbut in your function you are returning. please add more details.