Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import subprocess
  2. import csv
  3.  
  4.  
  5. pl = subprocess.Popen(["snmptable", "-v2c", "-c", "public", "104.236.166.95",
  6. "hrSWRunTable"], stdout=subprocess.PIPE).communicate()[0]
  7. print(pl.decode("utf-8"))
  8. pll = pl.decode("utf-8")
  9. text_file = open("Output.txt", "w")
  10. text_file.write(pll)
  11. text_file.close()
  12.  
  13. with open('Output.txt') as infile, open('coordv.csv', 'w') as outfile:
  14. for line in infile:
  15. outfile.write(" ".join(line.split()).replace(' ', ','))
  16. outfile.write(",")
  17.  
  18. with open('Output.txt') as infile, open('coordv.csv', 'w') as outfile:
  19. writer = csv.writer(outfile)
  20. for line in infile:
  21. writer.writerow(line.split()) # ... or whatever you'd need in the rows
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement