[Tutor] Extracting columns from many files to different files

Joel Goldstick joel.goldstick at gmail.com
Mon Jul 16 18:58:39 CEST 2012


On Mon, Jul 16, 2012 at 12:24 PM, susana moreno colomer
<susana_87 at hotmail.com> wrote:
> 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
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
Its great that you are using spaces in your code editor, but the
reason your code isn't formatted in your emails is that you have rich
text editing or html editing on.  If you are using gmail, you can tell
this because it gives a word processor style ribbon of buttons at the
top of your edit window.


-- 
Joel Goldstick


More information about the Tutor mailing list