google / textfsm

Python module for parsing semi-structured text into python tables.
Apache License 2.0
1.11k stars 171 forks source link

Loading "standard template" gives 'str' has no attribute 'seek' #94

Closed rtrunk closed 2 years ago

rtrunk commented 3 years ago

print(textfsm.version) 1.1.0 type="nxos" template = os.environ['NETTEXTFSM'] + "\cisco" + type + "_show_cdp_neighbors_detail.textfsm" print("Using: " + template) Using: C:\repos\ntc-templates\templates\cisco_nxos_show_cdp_neighbors_detail.textfsm try: ... mylist=textfsm.TextFSM(template) ... except Exception as e: ... print(e) ... 'str' object has no attribute 'seek'

geekstrident commented 2 years ago

change this line

mylist=textfsm.TextFSM(template)

to

from io import StringIO
mylist = textfsm.TextFSM(StringIO(template))