[Tutor] Tab delimited file

kumar s ps_python at yahoo.com
Tue Nov 2 18:29:07 CET 2004


Dear Group, 
 I have a tab-delimited text file with 100 columns. 

I wanted to write every first column and every
alternative column starting from 2-100 in to a file. 

For example:
Column 1 is names of my genes.
Column 2 - 100 are experiments done to check those
genes in various samples. 

Now I want to write column 1 and column 2 as file1.
Column1 and column3 as file2. 
Col. 1 and col. 4 as file 3 ..so on and so forth. 


import string
from string import strip

f1 = open('file1.txt','r')
f2 = open('sub_file2.txt','w')
list = f1.read()
list1 = split(list,'\n')
for all lines in range(len(list1)):
         columns = split(list1[i],'\t')


>From now on It proved difficult for me to progress
ahead. How can I ask column 1 and column 2 to be
written to sub_file2.txt. 

Can any one please help. 

What I do not know is:
1.how can I ask python to choose specific data only in
column2, 3 4 ....like that. 

2. I do not know I can ask python to iterate over each
row and asking it to write only column 1 and column 2
and nothing else. 

Please help me and this is a stumblick block for me. 


Thanks

Kumar

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Tutor mailing list