[Tutor] creating a tab delim file
Srinivas Iyyer
srini_iyyer_bio at yahoo.com
Tue Apr 18 20:53:58 CEST 2006
Hi group,
I asked similar questions in the past. I am unable to
get to the crux of this problem so that I can solve on
my own. apologies for my ignorance.
The problem:
I have 50 tab delim files. Each file has 500 rows and
50 columns.
I have to read the first column of each file. Repeat
the same for 50 files and write a tab delim text file
containing 500 rows and 50 columns.
code that works through half of the problem:
import glob
files = glob.glob('*.proc')
for each in files:
f = open(each,'r')
da = f.read().split('\n')
dat = da[:-1]
for m in dat:
mycol = m.split('\t')[0]
..................
>From here I am blanked out. Although I can extract the
first column from each file:I have no idea how to
store each list.
thought 1. Create an empty string and join each by a
tab.
##
mycol = ''
for m in dat:
mycol = m.split('\t')[0]
mstr = '\t'.join(mycol)
how can i append the data from second file to that
string.
could tutors help me with this situation.
Thanks
srini
__________________________________________________
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