#1
|
|||
|
|||
cells from csv
Main goal:
1. open CSV file <- success 2. read column 1 and 2 and place them in a prompt <-success but may not be right 3. prompt value is then used to go to the correct row and then get column 3 ip address 4. next it will ssh. <-SSHing is not an issue. CSV file Code:
1 | SVL | 10..23 2 | FRP | 10..30 3 | TUK | 10..38 4 | MIN | 10..100 5 | CHR | 10..202 Code:
# $language = "python" # $interface = "1.0" crt.Screen.Synchronous = True def main(): import csv import os strHome = os.path.expanduser('~') strPathToFileCSV = "{0}/Documents/SecureCRT_Director_list.csv".format(strHome) strPathToFileCSV = strPathToFileCSV.replace('\\','/') with open(strPathToFileCSV) as objCSV: csv_reader = csv.reader(objCSV) next(csv_reader) varX="" data =str (csv_reader) for line in csv_reader: varX += line[0]+'. ' + line[1]+ ' ' VarDir = crt.Dialog.Prompt(varX) with open(strPathToFileCSV) as objCSV: csv_reader = csv.reader(objCSV) for row in enumerate(csv_reader): crt.Dialog.MessageBox(str(row[1])) main() |
#2
|
|||
|
|||
Hi Neisany,
Do you have a question? Are you seeking assistance? Or is this just something you are posting for the community?
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
Sorry I forgot to ask my questions
I need assistance in step 3. I cant seem to pick a row and a column. I know this should be a simple task but I cant seem to make it work. essential I need the prompt value example = 2 to look at the table and grab row 2 column 3 |
#4
|
|||
|
|||
Hi Neisany,
That's more Excel/Python than it is SecureCRT. ![]() Take a look at the newly posted example from our script examples "sticky": Example: Python - Lookup Data from CSV File Using CSV ReaderIt should provide you with an example of accomplishing something similar to what you need.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 Last edited by jdev; 01-24-2020 at 05:17 PM. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | Rate This Thread |
|
|