Need some help sorting the results from .findall in python to convert the results in some readable format. I have a snippet giving me following output
[('Jul 11 11:25:51', 'ul 11 11:25:51', '', '', ''), ('', '', 'u2k', '', ''), ('', '', '', 'CBDCS2.CTP', ''), ('Jul 11 11:25:52', 'ul 11 11:25:52', '', '', ''), ('', '', 'u2k', '', ''), ('', '', '', 'WNDCS2.WTC', ''), ('Jul 11 11:25:53', 'ul 11 11:25:53', '', '', ''), ('', '', '', '', 'interface GigabitEthernet 2/0/44 '), ('', '', 'lqin', '', ''), ('', '', '', 'CASWNTHS151', ''), ('Jul 11 11:25:55', 'ul 11 11:25:55', '', '', ''), ('', '', 'u2k', '', ''), ('', '', '', 'asuspmk02', ''), ('Jul 11 11:25:55', 'ul 11 11:25:55', '', '', ''), ('', '', 'u2k', '', ''), ('', '', '', 'h_asuspmk01', ''), ('Jul 11 11:26:13', 'ul 11 11:26:13', '', '', ''), ('', '', '', 'cis1tow', ''), ('Jul 11 11:26:32', 'ul 11 11:26:32', '', '', ''), ('', '', '', '', 'show rpl route-policy RP-AKAMAI-LDV-OUT attachpoints '), ('', '', 'lyang', '', ''), ('', '', '', 'bgnzldv02', ''), ('Jul 11 11:26:32', 'ul 11 11:26:32', '', '', ''), ('', '', '', '', 'switchport voice vlan 462 '), ('', '', 'lqin', '', ''), ('', '', '', 'CASWNTHS151', ''), ('Jul 11 11:26:38', 'ul 11 11:26:38', '', '', ''), ('', '', '', '', 'copy running-config startup-config '), ('', '', 'lqin', '', ''), ('', '', '', 'CASWNTHS151', ''), ('Jul 11 11:26:57', 'ul 11 11:26:57', '', '', ''), ('', '', 'lqin', '', ''), ('', '', '', 'CASWNTHS151', '')]
Need output as
Jul 11 11:25:51 ul 11 11:25:51 u2k CBDCS2.CTP
Jul 11 11:25:51 ul 11 11:25:51 u2k WNDCS2.WTC
and so on
Snippet as below
p = re.compile(r'([J](\S+\W+\S+\W+\S+))|User=(\S\S+),|NetworkDeviceName=(\S\S+),|CmdAV=([^\<]*)')
results = re.findall(p,output)
file4.write(str(results))
input as follows
Jul 11 11:58:37 CSCOacs_TACACS_Accounting 0034182898 1 0 2016-07-11 TACACS+ Accounting with Command, ACSVersion=acs-5.6.0.22-B.225, ConfigVersionId=18, Device IP Address=10.125.89.1, CmdSet=[ CmdAV=show rpl route-policy RP-GGC-CTP-OUT attachpoints <cr> ], RequestLatency=0, Type=Accounting, Privilege-Level=0, Service=Login, User=lyang, Port=/dev/vty10, Remote-AVPair=priv-lvl=0, AcctRequest-Flags=Stop, Service-Argument=shell, AcsSessionID=imau03ftc/256670213/33719073, NetworkDeviceName=u2k NetworkDeviceGroups=All Devices:All