2

I would like to pull data from 2 columns (Input & Surname) from a table that is saved as a .txt file and then generate an output file (by writing a script) with the two columns (Input and Surname). I know how to do this with normal lines but have no idea where to start with a table format.

Example table -

Input Name Middle-name Surname Gender
123 Sam Mitchell Grant Male
123 Sameuel n/a Fineus Male
123 Sharron Elizabeth Graceson Female

Actual data -

Input   Input Type  MGI Gene/Marker ID  Symbol  Name    Feature Type
GO:0003723  Gene Ontology (GO)  MGI:87879   Aco1    aconitase 1 protein coding gene
GO:0003723  Gene Ontology (GO)  MGI:88022   Ang angiogenin, ribonuclease, RNase A family, 5 protein coding gene
GO:0003723  Gene Ontology (GO)  MGI:88042   Apex1   apurinic/apyrimidinic endonuclease 1    protein coding gene

The second row of the table starts from GO:0003723 and each new row starts with GO:0003723 as well.

  • 1
    Please open your .txt input file with a text editor, then copy and paste the contents of the file enclosed by triple backquotes ``` into your question, so that we can see what the file looks like. – TheEagle Oct 09 '21 at 19:17
  • @pythonstudent, is there anything in this question very specific to python 3.8? (as i see, I don't think so). if not, then please change the tag to [tag:python] – Akshay Sehgal Oct 09 '21 at 19:41

1 Answers1

1

You can use the csv module to parse tab seperated value files as shown here.