-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCostDimension.py
36 lines (31 loc) · 1.58 KB
/
CostDimension.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from DimensionTable import DimensionTable
import os
from utils import utils
from Config import OUTPUT_DIR
class CostsDimension(DimensionTable):
def __init__(self, cost_dict):
DimensionTable.__init__(self, os.path.join(OUTPUT_DIR, 'costs.csv'),
["CostsKey",
"EstimatedTotalCost", "NormalizedTotalCost",
"FederalPayments",
"ProvincialDeptPayments",
"ProvincialDFAAPayments",
"InsurancePayments"])
self.row_counter = 0
self.cost_dic = cost_dict
def parse(self, record, head):
"""Extract cost values from the record"""
etc = utils.extract_float(record, head['ESTIMATED TOTAL COST'])
ntc = utils.extract_float(record, head['NORMALIZED TOTAL COST'])
fdp = utils.extract_float(record, head['FEDERAL DFAA PAYMENTS'])
pdp = utils.extract_float(record, head['PROVINCIAL DEPARTMENT PAYMENTS'])
pdap = utils.extract_float(record, head['PROVINCIAL DFAA PAYMENTS'])
ip = utils.extract_float(record, head['INSURANCE PAYMENTS'])
string = str(etc) + "," + str(ntc) + "," + str(fdp) + "," + str(pdp) + "," + str(pdap) + "," + str(ip)
if string in self.cost_dic.keys():
return self.cost_dic[string]
else:
self.row_counter += 1
self.cost_dic[string] = self.row_counter;
self.write_row((self.row_counter, etc, ntc, fdp, pdp, pdap, ip))
return (self.row_counter)