def outcomestats(inputfile, outputfile, configfile, originrow, origincolumn): # load entire jason file. (Note: syntactically it is a Dictionary !!! ) with open(inputfile) as data_file: fpAkkaOutput = json.load(data_file) ###### In this test, both normalized and non-normalized statistics are shown ### origin1 = [0, 0] # Validator names, from which cell addr set below has names for non-normalized data ### origin2 = [5, 0] # Validator names, from which cell addr set below has names for non-normalized data ### origin1 = [origincolumn,originrow] origin1 = [origincolumn,originrow] workbook = xlsxwriter.Workbook(outputfile) # xlsxwriter model of an xlsx spreadsheet worksheet = workbook.add_worksheet() # should supply worksheet name, else defaults # stats = OutcomeStats(workbook,worksheet,data_file,outfile,configFile,origin1,origin2) stats = OutcomeStats(configfile) ### worksheet.set_column(0, len(stats.getOutcomes()), 3 + stats.getMaxLength()) ### worksheet.set_column(origincolumn, len(stats.getOutcomes()), 3 + stats.getMaxLength()) worksheet.set_column(origincolumn, len(stats.getOutcomes()), 3 + stats.getMaxLength()) # print(stats.getOutcomes()) outcomeFormats = OutcomeFormats({}) formats = outcomeFormats.initFormats(workbook) # shouldn't be attr of main class ################################################### #####createStats and stats2XLSX comprise the main # # processor filling the spreadheet cells #### ################################################### # if stats are normalized, results are divided by number of records # otherwise, cells show total of the number of each outcome in the appropriate column normalized = True validatorStats = stats.createStats(fpAkkaOutput, ~normalized) validatorStatsNormalized = stats.createStats(fpAkkaOutput, normalized) outcomes = stats.getOutcomes() # print("outcomes=", outcomes) validators = stats.getValidators() stats.stats2XLSX(workbook, worksheet, formats, validatorStats, origin1, outcomes, validators) ### stats.stats2XLSX(workbook, worksheet, formats, validatorStatsNormalized, origin2, outcomes, validators) workbook.close()
#load entire jason file. (Note: syntactically it is a Dictionary !!! ) with open(args.getInfile()) as data_file: fpAkkaOutput=json.load(data_file) ###### In this test, both normalized and non-normalized statistics are shown origin1 = [0,0] #Validator names, from which cell addr set below has names for non-normalized data origin2 = [5,0] #Validator names, from which cell addr set below has names for non-normalized data outfile = args.getOutfile() workbook = xlsxwriter.Workbook(outfile) #xlsxwriter model of an xlsx spreadsheet worksheet = workbook.add_worksheet() #should supply worksheet name, else defaults configFile= 'stats.ini' # stats = OutcomeStats(workbook,worksheet,data_file,outfile,configFile,origin1,origin2) stats = OutcomeStats(workbook,worksheet,args,origin1,origin2) worksheet.set_column(0,len(stats.getOutcomes()), 3+stats.getMaxLength()) # print(stats.getOutcomes()) outcomeFormats = OutcomeFormats({}) formats = outcomeFormats.initFormats(workbook) #shouldn't be attr of main class ################################################### #####createStats and stats2XLSX comprise the main # # processor filling the spreadheet cells #### ################################################### #if stats are normalized, results are divided by number of records #otherwise, cells show total of the number of each outcome in the appropriate column normalized = True validatorStats = stats.createStats(fpAkkaOutput, ~normalized) validatorStatsNormalized = stats.createStats(fpAkkaOutput, normalized) outcomes = stats.getOutcomes() # print("outcomes=", outcomes) validators = stats.getValidators() stats.stats2XLSX(workbook, worksheet, formats,validatorStats,origin1, outcomes,validators)