python - function prints whole file, but only prints one line outside function -


i trying search file chromosomes want, such chr1.

i parsed file columns want in function get_columns(). when print parsed filed in function works fine. however, when try search word using returned file, seems though giving me first line. assigned variable search_file function , when print out first line of parsed file. how can search chromosome throughout whole file parsed in first function?

#! /usr/bin/python      input_file = open( "code_work/genfile.txt", "ru" )  def get_columns (myfile):         arow in myfile:         no_new = arow.lstrip("\n")         split = no_new.split('\t')         sec_split = split[8].split(';')          new_file =  split[0] + "\t" + split[3] + "\t" + split[4] + "\t" + split[6]  + "\t"  + sec_split[0]  + "\t" + sec_split[1]  + "\t" + sec_split[2]          return new_file              search_file = get_columns(input_file)   import re original = raw_input('enter word:') print re.findall(r"\b" +  re.escape(original) + "[\w]*", search_file)  input_file.close() 

you have return statement inside for loop. means function returns after first line.


Comments