0

I am getting an runtime error; when I remove "try except", it says invalid syntax at first letter of line tagstats = open("rramtag256.txt", 'r')

My rramtag256.txt definitely has the strings being searched

import sys
import os
import string

    tagstats = open("rramtag256.txt", 'r')
    list=[]
    for line in tagstats:
            if "Tag array:  Total dynamic read energy/access" in line:
                    s=line.split()
                    print s[0]
                    x=1
            if 'Area Components:' in line:
                    if 'Total leakage read/write power of a bank' in list:
                            s=list.split()
                            print s[0]
            if x==1:
                    list.append(line)

    tagstats.close()

Thanks,

1
  • 9
    That's probably the indentation error. You need to dedent your code back. Commented Feb 9, 2013 at 22:19

1 Answer 1

2

Python uses leading whitespace to determine what lines of code go together. In your case you have code in the main block both with zero leading whitespace (the import statements) and with 4 spaces (starting with the line that the error mentions).

The whitespace needs to be consistent, so you need to dedent all of the code starting with tagstats = open...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.