Instantly share code, notes, and snippets.

@dnel / Secret
Created Jan 10, 2018

What would you like to do?
import csv
script="config firewall addrgrp\n"
with open('groups.csv', 'rb') as csvfile:
obj_reader = csv.reader(csvfile, dialect='excel')
for row in obj_reader:
if group_dict.get(row[0]):
group_dict[row[0]] = "%s \"%s\"" % (group_dict.get(row[0]),row[6])
group_dict[row[0]] = "\"%s\"" % row[6]
if len(row[8]) > 2:
comment_dict[row[0]] = "\"%s\"" % row[8]
for k in group_dict.keys():
segment = "edit \"%s\"\n set member %s\n" % (k,group_dict.get(k))
if comment_dict.get(k): segment += " set comment %s\n" % comment_dict.get(k)
segment += "next\n"
script += segment
script += "end\n"
with open('groups_script.fgt', 'w') as save_file: save_file.write(script)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment