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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:49:40+00:00 2026-06-06T11:49:40+00:00

I m trying to open up a text file and look for string Num_row_lables

  • 0

I m trying to open up a text file and look for string Num_row_lables. If the value for Num_row_labels is greater than or equal to 10, then print the name of the file.

In the example below, my text file test.mrk has some text in the format below: P.s., my text file doesn’t have Num_row_labels >= 10. It always has “equal to“.

Format= { Window_Type="Tabular", Tabular= { Num_row_labels=10 } }

so I created a variable teststring to hold the pattern I will be looking at.
Then I opened the file.

Then using re, I got Num_row_labels=10 in my variable called match.
Using group() on match, I extracted the threshold number I wanted and using int() converted the string to int.

My purpose is to read the text file to find/print the value for Num_row_labels along with the name of file if the text file has Num_row_labels = 10 or any # greater than 10.

Here’s my test code:

import os
import os.path
import re

teststring = """Format= { Window_Type="Tabular", Tabular= { Num_row_labels=10 } }"""
fname = "E:\MyUsers\ssbc\test.mrk"
fo = open(fname, "r")
match = re.search('Num_row_labels=(\d+)', teststring)
tnum = int(match.group(1))


if(tnum>=10):
        print(fname) 

How do I make sure that I m searching the match in the content of opened file and checking the condition for tnum>=10? My test code would simply print the file name only on the basis of last 4 lines. I want to be sure that the search is all over the content of my text file.

  • 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-06T11:49:42+00:00Added an answer on June 6, 2026 at 11:49 am

    so what you want to do is to read out the whole file as a string, and search for your pattern on that string

    with open(fname, "r") as fo:
        content_as_string = fo.read()
        match = re.search('Num_row_labels=(\d+)', content_as_string)
        # do want you want to the matchings
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to open a text file in python. In the following code:
so I'm trying to open a text file with a poem and see how
My application is trying to open a text file, and is presented with a
I'm trying to open an .html file as one big long string. This is
I'm trying to open a text file and output its contents with the code
I have the following code where I am trying to open a text file.
I am trying to use StreamReader and StreamWriter to Open a text file (fixed
I'm trying to read a text file with multiple lines and then display it
I am trying to open a text file one specific text file on my
I am trying open a very large file in Emacs and it fails to

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.