'''
python
import re
import pandas as pd
data = []
final_data=[]
current={'接口':'',"VLAN":'',"VPN":'',"类型1":'',"IPv4地址":'',"类型2":'',"IPv6地址":'',"OSPFv3进程":''}
with open('1.txt') as f:
for line in f.readlines():
if line.startswith("interface NULL0"):
break
if line.startswith('interface '):
if len(current["IPv4地址"]) == 0 and len(current["IPv6地址"]) == 0:
current = {'接口':'',"VLAN":'',"VPN":'',"类型1":'',"IPv4地址":'',"类型2":'',"IPv6地址":'',"OSPFv3进程":''}
else:
data.append(current)
current = {'接口':'',"VLAN":'',"VPN":'',"类型1":'',"IPv4地址":'',"类型2":'',"IPv6地址":'',"OSPFv3进程":''}
if line.startswith("interface "):
current["接口"]=re.findall(r"interface (.*)",line)[0]
elif line.startswith(' vlan-type dot1q '):
current["VLAN"]=re.findall(r" vlan-type dot1q (.*)",line)[0]
elif line.startswith(" ip binding vpn-instance "):
current["VPN"]=re.findall(r" ip binding vpn-instance (.*)",line)[0]
elif line.startswith(" ip address "):
current["IPv4地址"]=re.findall(r" ip address (.*)",line)[0]
current["类型1"]="IPv4"
elif 'ipv6 address auto link-local' in line:
pass
elif line.startswith(" ipv6 address "):
current["IPv6地址"]=re.findall(r" ipv6 address (.*)",line)[0]
current["类型2"]="IPv6"
elif line.startswith(' ospfv3 ') and line.endswith(" area 0.0.0.0\n"):
current["OSPFv3进程"]=re.findall(r" ospfv3 (.*) area 0.0.0.0",line)[0]
data.append(current)
final_data=filter(None,data)
df = pd.DataFrame(data)
df.to_excel('result.xlsx', index=False)
'''