def add_prices(self, sheet, companies, row, date_to_match, description):
     col = 1
     min = -1
     for company, dates in companies.items():
         for date_in_company in dates[description]:
             price_for_date = common.get_dict(date_in_company, date_to_match)
             if not price_for_date:
                 continue
             min = int(float(price_for_date)) if int(float(price_for_date)) < min or min == -1 else min
             sheet[self.to_string(row, col)] = {"value": price_for_date, "format": "number"}
         col += 1
     self.add_conditional_format(row, row, 1, col, min)
Example #2
0
 def add_prices(self, sheet, companies, row, date_to_match, description):
     col = 1
     min = -1
     for company, dates in companies.items():
         for date_in_company in dates[description]:
             price_for_date = common.get_dict(date_in_company,
                                              date_to_match)
             if not price_for_date:
                 continue
             min = int(float(price_for_date)) if int(
                 float(price_for_date)) < min or min == -1 else min
             sheet[self.to_string(row, col)] = {
                 "value": price_for_date,
                 "format": "number"
             }
         col += 1
     self.add_conditional_format(row, row, 1, col, min)
Example #3
0
from __future__ import division
"""
   Plot some Heritage files

"""
import common


if __name__ == '__main__':
    import sys
    import optparse

    parser = optparse.OptionParser('python ' + sys.argv[0] + ' options <file name>')
    parser.add_option('-i', '--histogram', dest='plot_histo', default=False, help='plot histogram')
  
    (options, args) =  parser.parse_args()
    
    if options.plot_histo:
        filename,column_key = options.plot_histo.split(':')
        title = filename
        vals = common.get_dict(filename, column_key, int).values()
        
        common.summarize(title, vals)
        plotter.plot_histo(title, vals)
        
        vals1 = [i for i in vals if i != 0]
        title1 = title + ' (0 excluded)'
        common.summarize(title1, vals1)
        plotter.plot_histo(title1, vals1)
     
    
Example #4
0
if __name__ == "__main__":

    parser = argparse.ArgumentParser()
    parser.add_argument('-lu', '--list_usecase', help='List usecases', action='store_true')
    parser.add_argument('-ln', '--list_nid', help='List available NIDs', required=False)
    parser.add_argument('-u', '--usecase', help='Usecase to be provisioned', required=False)
    parser.add_argument('-n', '--nid', help='NID to be provisioned', required=False)
    args = parser.parse_args()

    usage = "ERROR!!\nUsage: config_builder.py --usecase \"Usecase name\" --nid \"NID\""
    usage2 = "Verify: config_builder.py --list_nid \"usecase\""
    usage3 = "Verify: config_builder.py --list_usecase"

    gusecase = common.read_usecase(usecase_file)
    usecase = common.get_dict(gusecase, 0)

    if args.list_usecase:
        common.list_keys(usecase)
        print usecase['Inter_State_EVC_EREACH_Over_ACCESS_EPL']['vendor'].keys()
        exit()
    elif args.list_nid:
        if args.list_nid in usecase:
            common.list_keys(usecase[args.list_nid]['vendor'])
        else:
            print "ERROR!! usecase not found\n" + usage3
        exit()
    elif args.nid and args.usecase:
        if args.usecase in usecase:
            if args.nid in usecase[args.usecase]['vendor']:
                print "Success"
Example #5
0
def get_dih(year):
    """Return "days in hospital" spreadsheet for specified year 
        DaysInHospital_Y?.csv as a dict
    """
    return common.get_dict(get_dih_filename(year), 'DaysInHospital', int)