Jan-14-2022, 06:30 PM
These brackets and quotes always cause me grief.
If I create the list from reading a csv file then print the list, it prints with brackets.
['NODE001']
['NODE002']
['NODE003']
['NODE004']
This breaks my SSH API code which appears to be reading the item with the brackets and not the actual item. If I can get print to print correctly then my app should work. The problem appears to be how the list is written. This shouldn't be that hard. Help.. please?
If I create the list on the fly eg. list=["item1", "item2", "item3"] it prints only the items without bracket and quotes.
NODE001
NODE002
NODE003
NODE004
The SSH API works fine with above.
Thanks much!
If I create the list from reading a csv file then print the list, it prints with brackets.
import csv with open ('csvtest2.csv','r') as csv_file: reader =csv.reader(csv_file) included_cols = [0] next(reader) # skip first row gateways =[] for row in reader: content = list(row[i] for i in included_cols) gateways.append (content) print(*gateways, sep = "\n")OUTPUT:
['NODE001']
['NODE002']
['NODE003']
['NODE004']
This breaks my SSH API code which appears to be reading the item with the brackets and not the actual item. If I can get print to print correctly then my app should work. The problem appears to be how the list is written. This shouldn't be that hard. Help.. please?
If I create the list on the fly eg. list=["item1", "item2", "item3"] it prints only the items without bracket and quotes.
gateways = ["NODE001", "NODE002", "NODE003", "NODE004"] print(*gateways, sep = "\n")OUTPUT:
NODE001
NODE002
NODE003
NODE004
The SSH API works fine with above.
Thanks much!
Attached Files