def ExportResults(data,cms,export):
#var's of excel
# Start from the first cell. Rows and columns are zero indexed.
row = 0
col = 0
i = 0
#json
if (export == 1):
print "Exporting the results in a json"
for domain in data:
for j in cms:
filename = "output_domains" + code + ".json"
with open(filename, 'w') as f:
json.dump(domain,j, f)
#excel
if (export ==2):
print "Exporting the results in an excel"
# Create a workbook and add a worksheet.
workbook = xlsxwriter.Workbook('Status_domains.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write(row, col, "Domain")
worksheet.write(row, col+1, "cms")
row += 1
# Iterate over the data and write it out row by row.
for domain in data:
col = 0
worksheet.write(row, col, domain)
worksheet.write(row, col+1, cms[i])
row += 1
i += 1
#close the excel
workbook.close()
评论列表
文章目录