[Tutor] Extracting columns from many files to different files

susana moreno colomer susana_87 at hotmail.com
Mon Jul 16 18:24:51 CEST 2012


They are separated by tabs

> Date: Mon, 16 Jul 2012 12:16:22 -0400
> Subject: Re: [Tutor] Extracting columns from many files to different files
> From: joel.goldstick at gmail.com
> To: taserian at gmail.com
> CC: susana_87 at hotmail.com; tutor at python.org
> 
> On Mon, Jul 16, 2012 at 12:11 PM, taserian <taserian at gmail.com> wrote:
> > On Mon, Jul 16, 2012 at 10:58 AM, susana moreno colomer
> > <susana_87 at hotmail.com> wrote:
> >>
> >> Hi!
> >> I have a folder, with the following text files with columns:
> >>
> >> bb_ 1
> >> bb_2
> >> ww_1
> >> ww_2
> >> ff_1
> >> ff_2
> >>
> >> What I want to do is:
> >>
> >> Extract columns 5,6, 8 from files bb_
> >> Extract columns 3,4 from files ww_
> >> Get 5 files, corresponding to different columns:
> >> Files (excel files): 'ro' with colums number 5,  'bf' with colums number
> >> 6,  'sm' with column 8,  'se' with columns number 3 and  'dse' with columns
> >> number 4
> >
> > How are these columns separated? Blank spaces, tabs, commas?
> >
> > I'm mostly worried about:
> >
> >
> > for b in line:
> >     A.append(b[5].strip())
> >     B.append(b[6].strip())
> >     C.append(b[8].strip())
> >
> > For the A List, this will take the 5th character from the line, not the 5th
> > column. You may need to split the line based on the separators.
> >
> > AR
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > To unsubscribe or change subscription options:
> > http://mail.python.org/mailman/listinfo/tutor
> >
> To make your code show correctly you must set your email program to
> write text and not html.  You should also set your text editor to turn
> tabs into 4 spaces.  Tabs work in python, but you can't mix tabs and
> spaces, so it is less of a problem if you only use spaces for
> indenting
> 
> 
> -- 
> Joel Goldstick
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120716/0b1bc4bf/attachment.html>


More information about the Tutor mailing list