How to use findall to find keywords in file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Billy Green

    #1

    How to use findall to find keywords in file

    I'm new to python and was trying to write a (re.findall) code to find stings containing a certain keyword in my file.

    This is the code I'm using and I'm getting error messages??? Please help..

    q6=open('file1. txt','r')
    >>> lines=q6.readli nes()
    >>> for i in lines:
    ... element = re.findall('[^\+\n]+' i),,,,,error message
    if element[2]=='chr22'
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    You left out the comma between the pattern and string arguments.

    Comment

    Working...