Question: This is how i made my CSV file:

```
with open('Mail_Txt.csv', 'w', encoding='utf-8', newline='') as csvfile:
    fieldnames= ['Sender', 'Subject', 'Snippet']
    writer = csv.DictWriter(csvfile, fieldnames=fieldnames , delimiter=',')
    for val in final_list:
        writer.writerow(val)

```

I try many methods to print the Sender column of the CSV file. But I fail all the time. so, help me to print the first or `'Sender'` column of the CSV file

Answer: 
I have stored device configuration in device\_config.cfg file. using ciscoconfparse and regex module I am able to do this.

```
from ciscoconfparse import CiscoConfParse
import re

final_list = []
cisco_file = 'device_config.cfg'

cisco_cfg = CiscoConfParse(cisco_file)
parent_child_line = cisco_cfg.find_objects_w_child(parentspec=r"", childspec=r"10.10.10.10")
parsed_data = cisco_cfg.find_objects(r"10.10.10.10")

# print(parent_child_line)
# print(parsed_data)

for p_line in parent_child_line:
    # print(p_line.text)
    final_list.append(p_line.text)
    for child in p_line.children:
        if re.search(r'10.10.10.10', child.text):
            # print(child.text)
            final_list.append(child.text)

print('\n#############################################\n')

for i in parsed_data:
    if not re.search(r'^\s\w', i.text):
        # print(i.text)
        final_list.append(i.text)
        print(final_list)

```
```py
import re
reg = r' .*10\.10\.10\.1.*'
data = """
ip access-list extended test1
 deny   tcp any eq tacacs any
 permit ip any any
ip access-list extended test2
 permit ip any any
 permit ip host 10.10.10.1 any log
 permit icmp host 10.10.10.2 any
 permit tcp any any eq 22
 permit tcp any any eq tacacs
 permit tcp any any
 permit udp any any
ip access-list extended test3
 permit udp any any eq 123 log
 permit udp any any eq 1234 log
 permit ip any any
""" #read your data your way (open(file) or args)
dataLines = data.split('\n')
while '' in dataLines:
    dataLines.remove('')
print(dataLines)
parent = ''

for i in dataLines:
    if not i[0] == ' ':
        parent = i
        continue
    else:
        if re.match(reg, i):
            print('\n'+parent)
            print(i)
            break

```

This might help...