Python Forum
Need to create a dictionary from a *.csv
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need to create a dictionary from a *.csv
#5
Thanks for your patience.

For netmiko, I need the following information to establish a connection.

net_conn = Netmiko(host='xxxxxx', username='test',
password=getpass(), device_type='cisco_ios')

So, from the *.csv file, I'd like to somehow create a dictionary of the devices so I can just call the dictionary to establish SSH sessions.

Now, in some examples I see this -

testswitch = {'ip': 'x.x.x.x',
'device_type': 'cisco_ios',
'username': 'user',
'password': 'password'}

devices - [testswitch, and then listing the rest of the devices]

for device in devices:

So, I'm wondering if it is possible to pull that information from the csv file automatically or if I need to manually create a host file of all my devices first and call that file.
Reply


Messages In This Thread
RE: Need to create a dictionary from a *.csv - by 74razor - Dec-18-2019, 04:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Create new dictionary angus1964 6 3,758 May-08-2022, 12:43 PM
Last Post: snippsat
  Create new dictionary angus1964 2 1,962 May-06-2022, 02:14 PM
Last Post: deanhystad
  Create a dynamic Menu from a editable Dictionary. KiNeMs 1 3,046 Jan-28-2020, 04:27 AM
Last Post: Larz60+
  Create a dictionary from a list klllmmm 3 3,877 Oct-06-2019, 05:50 PM
Last Post: Gribouillis
  Create XML from dictionary pygrrrl 7 192,566 Jul-29-2019, 08:33 PM
Last Post: pygrrrl
  Better way to create nested dictionary with defaultdict() x2mlh 8 25,561 Nov-30-2017, 08:10 PM
Last Post: buran
  create dictionary from **kwargs that include tuple bluefrog 2 6,113 Oct-26-2016, 10:24 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020