Beema Shafreen wrote:
As an aside, you should change the above line to:
for line in fh:
"readlines( )" will read the entire file into memory at once, while just
iterating through it won't, so you'll save memory on large files.
This is very trivial, but you could change the above line to:
result = "\t".join(i d, gene_symbol, ptms)
--
hi all,
>
I have a script using functions , I have a problem in returning the
result. My script returns only one line , i donot know where the looping
is giving problem, Can any one suggest, why this is happening and let me
know how to return all the lines
>
def get_ptm():
fh = open('file.txt' , 'r')
data_lis = []
for line in fh.readlines():
>
I have a script using functions , I have a problem in returning the
result. My script returns only one line , i donot know where the looping
is giving problem, Can any one suggest, why this is happening and let me
know how to return all the lines
>
def get_ptm():
fh = open('file.txt' , 'r')
data_lis = []
for line in fh.readlines():
for line in fh:
"readlines( )" will read the entire file into memory at once, while just
iterating through it won't, so you'll save memory on large files.
data = line.strip().sp lit('\t')
id = data[0].strip()
gene_symbol = data[1].strip()
ptms = data[8].strip()
result = "%s\t%s\t%s " %(id,gene_symbo l,ptms)
id = data[0].strip()
gene_symbol = data[1].strip()
ptms = data[8].strip()
result = "%s\t%s\t%s " %(id,gene_symbo l,ptms)
result = "\t".join(i d, gene_symbol, ptms)
return result
fh.close()
fh.close()