[Tutor] Extracting columns from many files to different files
taserian
taserian at gmail.com
Mon Jul 16 18:11:33 CEST 2012
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120716/c35c63c7/attachment.html>
More information about the Tutor
mailing list