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 250347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:30:12+00:00 2026-05-11T21:30:12+00:00

I have 3 text files many lines of value1<tab>value2 (maybe 600) many more lines

  • 0

I have 3 text files

  1. many lines of value1<tab>value2 (maybe 600)
  2. many more lines of value2<tab>value3 (maybe 1000)
  3. many more lines of value2<tab>value4 (maybe 2000)

Not all lines match, some will have one or more vals missing. I want to take file 1, read down it and lookup corresponding values in files 2 & 3, and write the output as – for example

value1<tab>value2<tab>value3<tab>value4
value1<tab>value2<tab>blank <tab>value4

i.e. indicate that the value is missing by printing a bit of text

in awk I can BEGIN by reading the files into arrays up front then END and step through them. But I want to use Python (3) for portability. I do it on a pc using MS Access and linking tables but there is a time penalty for each time I use this method.

All efforts to understand this in dictionaries or lists have confused me. I now seem to have every Python book!

Many thanks to anyone who can offer advice. (if interested, it’s arp, mac and vendor codes)

  • 1 1 Answer
  • 1 View
  • 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-11T21:30:13+00:00Added an answer on May 11, 2026 at 9:30 pm

    Start with this.

    def loadDictionaryFromAFile( aFile ):
        dictionary = {}
        for line in aFile:
            fields = line.split('\t')
            dictionary[fields[0]]= fields
    
    dict2 = loadDictionaryFromAFile( open("file2","r" )
    dict3 = loadDictionaryFromAFile( open("file3","r" )
    
    for line in open("file1","r"):
        fields = line.split("/t")
        d2= dict2.get( fields[0], None )
        d3= dict3.get( fields[0], None )
        print fields, d2, d3
    

    You may want to customize it to change the formatting of the output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many large (~30 MB a piece) tab-delimited text files with variable-width lines.
I have a tab-delimited text file that is very large. Many lines in the
I have many text files containing bank transactions in the middle of them. Each
I have many text files, their total size is about 300GB ~ 400GB. They
I have a few text files and I'd like to count how many times
Like many, I have spreadsheet that draws data from over 40 text files as
I have a directory of text-based, compressed log files, each containing many records. In
I have a source of strings (let us say, a text file) and many
I have text files containing structured data (it is a proprietary format and not
I have two text files in two different languages and they are aligned line

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.