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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:29:55+00:00 2026-06-06T05:29:55+00:00

I just started using/learning Python and have some questions. I have a text file

  • 0

I just started using/learning Python and have some questions.

I have a text file generated by the reporting tool.
The file contains some stuff like this. There are many stuff which basically follow the same format as the one written below.

Format=
{
Window_Type=”Tabular”,
Tabular=
{ Num_row_labels=5
}
}

There are named value attributes in this file.
For e.g., Window_Type is the name of the attribute having value Tabular.
Again for Tabular named attribute has a value 5 associated with it.

What I want to be able to do is Open up the file.

  1. Check if Window_Type is Tabular
  2. If yes, then check the Num_row_labels associated with Tabular.
  3. If Num_row_lables has a value greater than or equal to 5, then print the name of the text file and the path of the folder, where that file exists.

I m using Python 3.2 in Eclipse 3.7.2 IDE.

For a testing part, I imported my text file in the IDE and used the code below to read the file. In future I should be able to traverse the folder/s where the files with extension mrk are located.(This will be a known directory because we keep those files in there.) Please kindly help me out. Thanks a bunch!

import os.path
fn = os.path.join(os.path.dirname(__file__), 'Multitab.mrk')
with open(fn, 'r') as file: 
    print(file.read())
  • 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-06T05:29:57+00:00Added an answer on June 6, 2026 at 5:29 am

    Please note that this answer is a very dirty hack. That format is almost similar to JSON format, which prompted me to write an RE which will convert the string such that it can be cleanly parsed by json parser. This is what I did:

    import re
    import json
    
    s = """Format= {
    Window_Type="Tabular",
    Tabular= { Num_row_labels=5 } }"""
    
    s = "{" + re.sub(r'([a-zA-Z0-9_]+)=',r'"\1":', s) + "}"
    obj = json.loads(s)
    
    if obj['Format']['Window_Type'] == "Tabular":
        print "Its tabular!"
        numrows = obj['Format']['Tabular']['Num_row_labels']
        print "Numrows:", numrows
        if numrows >= 5:
            print "Print this fileName"
    

    OUTPUT:

    Its tabular!
    Numrows: 5
    Print this fileName
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started learning python version 3 and trying to create a file
I've just started learning about Gimp scripting using Python, and was wondering, how do
I have recently started learning Python and I have 2 questions relating to modules.
I've just started learning python and I'm using MacVim as my editor with the
I have just started learning to write apps for android using Eclipse. Where can
Just started learning PySide and is having problem with QTimer I have this #!/usr/bin/python
Just started learning Scheme. I'm using Dr. Racket as my compiler/interpreter. I need some
I have just started learning how to program Windows GUI's using the low level
I have just started using the python-twitter API and it requires me to register
Just started learning/using pipes and was wondering how to route file output of an

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.