So, I have a file and I need to read in from the columns of the file. The column contains frequency of genes as floats. The number of the column to be read in is column_number
variable. Then, all of the floats (there are only floats in the column) in that column should be appended to a list. So far I have gotten this far:
def read_column(file_name, column_number):
lines = file_name.readlines()
floats = []
for x in lines:
floats.append(x.split(" ")[column_number])
return floats
The file is passed in as an argument and does not need to be opened, since the test program creates and opens a temporary file with the genetic frequencies in it.
When I run this code I get the following error:
'str' object has no attribute 'readlines'
What is it that I'm doing wrong?