Preview:
import re

def getAllLinesWithMatchingSentence(filePath,sentence):
	"""
	Prints all the lines that has sentence in it
    
    filePath : str
    	path of a file to search
        worked for .txt , .log files
    
    sentence: str
    	string to search
    """
    
    with open(filePath,'r') as f:
        for line in f:
            match = re.search(r"{}".format(sentence),line)

            if match:
                print(line)

 # Following function prints all the lines in a filePath that matches given sentence
getAllLinesWithMatchingSentence(
    filePath= 'files/log1.log',
    sentence = "dataframe of shape")
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter