コード例 #1
0
def stats_to_xlsx(inputfile, outputfile, configfile):
    """Generic function with input and output.
    parameters:
        inputfile - the full path to the input file
        outputfile - the full path to the output file
        outputfile - the full path to the config file
    returns:
        success - True if the task is completed, otherwise False
    """
    # Check for required values
    if inputfile is None or len(inputfile)==0:
        logging.debug('No input file given in do_stuff()')
        return False

    if outputfile is None or len(outputfile)==0:
        logging.debug('No output file given in do_stuff()')
        return False

        # 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
    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())
    #   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()

    # Success
    return True
コード例 #2
0
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()
コード例 #3
0
   #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)
コード例 #4
0
    # 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)