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

  • Home
  • SEARCH
  • 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 9003705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:44:44+00:00 2026-06-16T00:44:44+00:00

I am trying to read an input file and match the line which contains

  • 0

I am trying to read an input file and match the line which contains “ToolVersionEdit” and then split based on “=” and get the second part..I am using the below..am not getting the desired output..where am I going wrong?input and expected ouput are given below

INPUT:

[BuildRequest]
BuildRequestVersion=4.4.21
BuildRequestType=Phone
BuildCommandComboBox=common/build/build.sh tz:A8064AAAAANAAT140029.1 tz_bid=AAAAANAA wcnss:A8064AAAAANAAW120072.1 wcnss_bid=SCAQBAF lpass:A8064AAAAANAZL140106.1 boot_9x15:M9615ACETRMAAB12171.1 boot_9x15_bid=ACEHRMAA rpm:A8064AAAAANAAR1100153.1 rpm_bid=AAAAANAAR modem_9x15:M9615ACEFWTAAM4010223.1 modem_9x15_bid=ACEFWTAA apps_9x15:M9615AFEHRMAA2745.1 apps_9x15_bid=AFEHRMAA rpm_9x15:M9615ACETRMAAR1100159.4 rpm_9x15_bid=AAAAANAAR boot:A8064AAAAANAAB12171.1 boot_bid=AAAAANAA lpass_9x15:M9615ACETRMAZL140105.3 apps:A8064AAAAANLGA2214074.1 dsps:A8064AAAAANAAS150007.1 dsps_bid=DSPSBLD
ToolVersionEdit=1.6.21
CheckSumCheckBox=0
PurposeEdit=
[BuildRequestComments]
LineCount=0

EXPECTED OUTPUT:-1.6.21

import re
import sys
file = "C:\Dropbox\Reference.brf"

lines = open(file ,'r').readlines()

for line in lines:
    if 'ToolVersionEdit' in line:
        line = line.strip('=')[1]

print line
  • 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-16T00:44:45+00:00Added an answer on June 16, 2026 at 12:44 am

    Your problem is that you are overwriting the line variable. You’re using the same variable as your looping variable as what you’re trying to cache. Also, you don’t need to continue the loop once you’ve found what you’re looking for.

    Another change I made was to remove the call to readlines. You can iterate over all the lines directly from the file object. Also, it’s bad form to (potentially) overwrite the file module with a variable, so I renamed that one too.

    import re
    import sys
    filename = "C:\Dropbox\Reference.brf"
    try:
        input_file = open(filename ,'r')
    except IOError as exc:
        print exc
    else:
        cached_line = ""
        for line in input_file:
            if 'ToolVersionEdit' in line:
                cached_line = line.split('=')[1]
                break
    
        print cached_line
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to read in a text input file that contains a list
I am trying to read an input file (if it exists) and then want
I'm trying to read a file which has input(time and price) as: 12:23:31 67
I'm trying to get this script to basically read input from a file on
I am trying to read in an input file 64 bits at a time,
I am trying to read values from an input file in Perl. Input file
i`ve been trying o use fscanf to read the an input file on my
I'm trying to get some data from a file, then parse it and pass
I am currently trying to read from an xml file which records the jobs
I am currently trying to read in names from an input file. The file

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.