Python or Shell script to Grep strings from input file and output in csv format

Hi Experts,

I am writing a python script to grep string from file and display output in csv file as in attached screenshot

Input file(result_EPFT_config_device)

Below is the python script i have prepared as of now. Only able to grep string and print it

import sys
import telnetlib
import os
import subprocess
import re
import csv

fh = open("result_EPFT_config_device", "r")
fh1 = open("testingAjay", "w+")
line = fh.readlines()
for lines in line:
        if re.search("(lpts punt excessive-flow-trap)", lines):
                m =  (lines.split(' '))
                print m[0], m[1], m[2]
        if re.search("(penalty-rate arp)", lines):
                n =  (lines.split(' '))
                print n[0], n[1], n[2]
        if re.search("(penalty-rate icmp)", lines):
                a =  (lines.split(' '))
                print a[0], a[1], a[2]
        if re.search("(penalty-rate igmp)", lines):
                b =  (lines.split(' '))
                print b[0], b[1], b[2]
        if re.search("(penalty-rate ip)", lines):
                c =  (lines.split(' '))
                print c[0], c[1], c[2]
        if re.search("(dampening)", lines):
                c =  (lines.split(' '))
                print c[0]
        if re.search("(non-subscriber-interfaces)", lines):
                c =  (lines.split('-'))
                print c[0], c[1], c[2]
        if re.search("(report-threshold 10)", lines):
                c =  (lines.split(' '))
                print c[0], c[1]

My script output :

Now here i want to put the output in csv file as shown in attached screenshot or as below in txt file

Could you please help me to achieve require output in csv format using python scripting or shell scrpting as shown in attached screesshot

Also posted (and currently on hold) at scripting - Python script to Grep strings from input file and output in csv format - Unix & Linux Stack Exchange