Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import csv
- pl = subprocess.Popen(["snmptable", "-v2c", "-c", "public", "104.236.166.95",
- "hrSWRunTable"], stdout=subprocess.PIPE).communicate()[0]
- print(pl.decode("utf-8"))
- pll = pl.decode("utf-8")
- text_file = open("Output.txt", "w")
- text_file.write(pll)
- text_file.close()
- with open('Output.txt') as infile, open('coordv.csv', 'w') as outfile:
- for line in infile:
- outfile.write(" ".join(line.split()).replace(' ', ','))
- outfile.write(",")
- with open('Output.txt') as infile, open('coordv.csv', 'w') as outfile:
- writer = csv.writer(outfile)
- for line in infile:
- writer.writerow(line.split()) # ... or whatever you'd need in the rows
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement