Skip to content Skip to sidebar Skip to footer

Merge Two Tab Delimited Text Files By One Common Column In Python

@tim-pietzcker I would like to merge two tab-delimited text files that share one common column. I have an 'identifier file' that looks like this (2 columns by 1050 rows): module 1

Solution 1:

Open the gene descripion file, and load a dictionary where key would be the gene number, and the value would be the sample description.

Then open the module file, and loop on its lines. For each line, look for the corresponding gene entry in the dictionary. Print the module, gene, sample description.

That's it! If you need more information, check how to read a file and use a dictionary in the python documentation.

Post a Comment for "Merge Two Tab Delimited Text Files By One Common Column In Python"