Parse cisco's "show ip route" output in Python 2.7

A

Antgoodlife

Hi All,

Long time reader, first time poster. I'm trying to parse the output
of the SHOW IP ROUTE command from a cisco router (It's a 3800 Series
IOS 12.4 although almost all should have same output format) and put
it into a CSV format to import into a database or spreadsheet.
While we of course have Static / Connected routes, we also have lots
of dynamic routing coming in via OSPF, BGP, RIP, etc...

The output of the command is easy enough for me to get into text files
via parimiko (on that, does this module or equivalent work on Python 3
yet?) .. it's just tough to present the data into a csv or tabbed
format.

To me, although I've done similar things in the past, it's a fairly
brutal output format to parse up. I was about to post some sample
input, but I am even having a hard time sanitizing the IP's for use on
this forum (Any utility for that?) as it's filled with IP addresses
that I cannot share. I'd love some python module if anyone has an
idea where I can get it?

Perl does seem to have something similar :
http://cpansearch.perl.org/src/MARKPF/Cisco-ShowIPRoute-Parser-1.02/Parser.pm
however, I'd like to keep it in python...

Mainly, did someone already do this so I don't have to reinvent this
wheel (which probably won't roll straight)?

Thanks in advance, and hopefully I've given enough information.. I've
been trying to parse it for about 9 hours... but the script get's
worse and worse as I keep finding flaws in my logic.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top