ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-tutor
python-tutor
[Tutor] creating a tab delim file
by Srinivas Iyyer other posts by this author
Apr 18 2006 11:54AM messages near this date
[Tutor] Help Entry !!! | [Tutor] Tutorial on bitwise Python?
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 
_______________________________________________
Tutor maillist  -  Tutor@[...].org
http://mail.python.org/mailman/listinfo/tutor
Thread:
Cesar Garcia
Srinivas Iyyer

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved