Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6905161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:09:00+00:00 2026-05-27T08:09:00+00:00

I have two tab delimited files, file 1 contains identifiers and file 2 has

  • 0

I have two tab delimited files, file 1 contains identifiers and file 2 has values related to these identifiers (or say it is a very big dictionary).

file 1

Ronny
Rubby
Suzie
Paul

file 1 has only one column.

file 2

Alistar Barm Cathy Paul Ronny Rubby Suzie Tom Uma Vai Zai
12      13    14   12     11   11   12    23 30  0.34 0.65
1       4     56   23     12   8.9  5.1   1  4    25  3

n number of rows are present in file 2.

what I want, if the identifiers of file 1 are present in file 2, I should have all the values related to it in an another tab delimited file.

Something like this:

Paul Ronny Rubby Suzie
12     11   11   12
23     12   8.9  5.1

Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:09:01+00:00Added an answer on May 27, 2026 at 8:09 am

    An example in Python that does the work in stream (ie: don’t need to load the full file before starting the output):

    # read keys
    with open('file1', 'r') as fd:
        keys = fd.read().splitlines()
    
    # output keys
    print '\t'.join(keys)
    
    # read data file, with header line and content
    with open('file2', 'r') as fd:
        headers = fd.readline().split()
        while True:
            line = fd.readline().split()
            if len(line) == 0:
                break
            print '\t'.join([line[headers.index(x)] for x in keys if x in headers])
    

    Output:

    $ python test.py 
    Ronny   Ruby    Suzie   Paul
    11      11      12      12
    12      8.9     5.1     23
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tab delimited files: File 1: 12 rows and 1 column File
Let's say I have a tab-delimited text file that contains data arranged in columns
In tab container let say I have two tabs [Tab1 & Tab2] Tab1 has
I have two tab delimited csv files (with headers) that I need to merge
I have two tab-delimited genome sequence files (SAM format), and I would like to
I have two files one is a tab delimited and one is a csv
I have a file that is tab-delimited and contains multiple tables each headed by
I have a data set that has two tab delimited columns that I plot
I have two tab delimited files, of 3 columns and n number of rows.
I have two tabs in my home page and each tab has one jquery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.