1

I have a list of linelists file as below.how do i make a list of only the 3rd column of the output(the one starting with 0.002147)this is how my output is

Walker
  • 19
  • 3

1 Answers1

0

Assuming linelists looks something like this:

l = ['col11\tcol21\tcol31\tcol41\tcol51',
     'col12\tcol22\tcol32\tcol42\tcol52']

you can select the third column with

col3list = [line.split("\t")[2] for line in l]

which gives you ['col31', 'col32'].

Based on the image you provided, it is not clear if the columns are separated by a tab or multiple spaces. If the separators are spaces, you would need to change the argument of the split function.

Something similar to your question was also already answered here.

In general I would recommend loading files with the python library pandas, which can handle all kinds of data loading and selection tasks for you.

SSteph
  • 91
  • 6