Parse Show Commands into Spreadsheets

Lesson 4 of 10

The Scenario

Your manager asks: "Give me a spreadsheet of every interface on every switch — status, speed, VLAN, and description." You have 30 switches. Manually? That is a full day. With AI? Twenty minutes.


The Prompt

Write a Python script that:
1. SSHs into each device from devices.csv using Netmiko
2. Runs "show interface status" on each switch
3. Parses the output into structured data (interface, status, vlan, duplex, speed, type)
4. Combines all devices into one pandas DataFrame
5. Exports to an Excel file "interface_report_[date].xlsx" with one sheet per device and a "Summary" sheet with all devices combined
6. Highlight any interfaces that are "err-disabled" in red

Use TextFSM with ntc-templates if available, otherwise parse with regex.

What AI Gives You

A script that automates the entire process — collect, parse, export. The pandas DataFrame makes it easy to filter, sort, and pivot the data.


Review and Validate

  • TextFSM templates are the cleanest way to parse CLI output. Ask AI to use ntc-templates — they have pre-built parsers for hundreds of show commands
  • Verify parsing accuracy on one device before running against all 30
  • Excel formatting: If the red highlighting does not work, ask AI to use openpyxl conditional formatting

Try It Yourself

Replace show interface status with any show command you regularly need in spreadsheet form: show ip arp, show mac address-table, show cdp neighbors detail.

Subscribe to unlock this lesson

₹7,999/year

Full access to all 10 lessons in this course, plus 74 more lab courses, quizzes, and AI mock interviews. 365 days.

Already have an account? Sign in