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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:32:51+00:00 2026-06-08T04:32:51+00:00

Sorry for not having a clear title. I’ll try to explain my question. I

  • 0

Sorry for not having a clear title. I’ll try to explain my question.

I have two files A and B.

The format of file A is something like this:

set_time 10 temp max 2 min 1 xyzzy
set_time 10 temp max 2 min 1 abcde
set_time 10 temp max 3 min 2 ersfg
set_time 8  temp max 2 min 0 fdfdf

File B looks like this:

xyzzy 7.5
abcde 8.5
ersfg 9.5
fdfdf 9.0

Now, what needs to be done is, I have to search for the last column names in file A (xyzzy, abcde, fdfdf, etc.) and replace the 2nd column values with those 2nd column values from file B.

So, the output should look like:

set_time 7.5 temp max 2 min 1 xyzzy
set_time 8.5 temp max 2 min 1 abcde
set_time 9.5 temp max 3 min 2 ersfg
set_time 9.0 temp max 2 min 0 fdfdf

Any help is appreciated. This is a part of a TCL flow.

  • 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-06-08T04:32:53+00:00Added an answer on June 8, 2026 at 4:32 am

    Read the second file with the mappings, something like this:

    set f [open file_B]
    set mapping [dict create]
    while {[gets $f l]} {
        if {[feof $f]} break
        dict set mapping {*}$l
    }
    

    Then process the original file by making set_time a command that outputs itself, while changing the desired value:

    proc set_time {num_to_replace temp max maxnum min minnum mapval} {
        puts "set_time [dict get $::mapping $mapval] $temp $max $maxnum $min $minnum $mapval"
    }
    

    and then just source the original data file:

    source file_A
    

    This assumes of course that the two files have no other lines in them that would mess up the processing.

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

Sidebar

Related Questions

Sorry the title may not be very clear. Basically I have a wrapper for
Sorry if the title is not clear. I am a bit confused about how
Random question, sorry if not appropriate for stackoverflow, but I didn't think it would
Sorry for the not so great title, but I'm curious how people build a
Sorry this is not a very well defined question, I am thinking about an
I could be not more sorry guys - the question was a very wrong
Sorry but I am not sure how to ask this question but I am
Hi I am a novice in JAVA. I have been getting this file not
Sorry for the noob question, but I'm having problems with JPA+Hibernate so I thought
If I have the following code (EDIT: Sorry if I wasn't clear, I want

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.