cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2131
Views
5
Helpful
3
Replies

Saving Various IOS Commands to Excel Spreadsheet

MikeyMastro
Level 1
Level 1

Hello all.

 

I want to preface this by saying i'm a novice when it comes to Python and automation.

 

I have a script that currently works, that essentially reads in a JSON file full of devices, uses Netmiko to connect to said devices, creates a folder per device based on hostname, runs a bunch of IOS commands against that host and then saves the output as a text file within the folder, with the text file name being the name of the command being run. 

 

So this is fine and dandy but I wanted to take it a step further and instead of creating folders and .txt files, I wanted to create an excel workbook, and have the output of the commands saved in lets say Column A, and each tab within that workbook is the name of the command being run.  The file would then be saved as the hostname along with an .xlsx extension.

 

This is where I get stuck.  I have little to no experience with openpyxl and after googling some things, I came across Pandas as well, which i'm unfamiliar with completely.  My google search led me to this specific location as there was a similar question posed regarding saving LLDP output in a similar fashion.  Unfortunately for me, it appeared to either be incomplete or my lack of knowledge was showing and I just didn't understand it fully (most likely).

 

I can share my current script if need be, but figured i'd ask the community for some assistance.  I assume both openpyxl and pandas would do the job?  Is one easier than the other?  Any help would be appreciated.  Thank you.

 

-Michael

3 Replies 3

Hello @MikeyMastro this video should walk you over the entire steps. https://youtu.be/Y4vfA11fPo0

 

Hope this helps!

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

Thank you @bigevilbeard, i'll check that out now.  I appreciate it.  Should I have further questions, i'll reply on this thread.

So I went through that (skimmed it looking for Pandas or Openpyxl) and I didn't see any of that.  I will watch it in full later on, but I was hoping to work with Openpyxl as I have what I feel is the majority of it down now.  

 

The part that i'm getting stuck on is that when I write to the excel worksheet, it will put everything into the first cell and that's it.  I was hoping for it to just paste the output STARTING with the first cell, and if it spans across or down multiple rows/columns, that's perfect.  It's the same as copying the output and manually pasting it into excel.  I can't figure out this part.  Close though!