# This script loads nominal distributor capacities based on ICP counts, which are used throughout the analysis.
#
# The workings are provided in 'ICP_charge_calculations_-_by_customer.xlsx' - which:
# - takes active ICP count data as of 2014
# - multiplies distributor ICP counts by the nominal capacities below, to get a total nominal capacity for each distributor's customers.
#
#  Metering category code:  1    2    3     4     5  Unmetered
#  Nominal capacity (kVA)  20  100  700	 1750  2500         20

USE tpm2;

CREATE TABLE icp_charge_allocation_by_customer (customer VARCHAR(30), nominal_mva DOUBLE);
LOAD DATA LOCAL INFILE 'c:\\mydir\\TPM\\preprocessing\\ICP_charge_allocation_-_by_customer.csv'
INTO TABLE icp_charge_allocation_by_customer
COLUMNS TERMINATED BY ','
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;

CREATE INDEX idx ON icp_charge_allocation_by_customer (customer);

/* checks */

SELECT customer FROM icp_charge_allocation_by_customer WHERE NOT (customer IN (SELECT customer FROM transmission_customers)); # should be none

