# This script loads input tables that are used in the calculation of the status quo HVDC charge.

USE tpm2;

CREATE TABLE hvdc_generator_to_party (generator VARCHAR(30), party VARCHAR(30));
LOAD DATA LOCAL INFILE 'c:\\mydir\\TPM\\Status_quo_HVDC\\generator_to_party.csv'
INTO TABLE hvdc_generator_to_party
COLUMNS TERMINATED BY ','
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;

CREATE INDEX idx ON hvdc_generator_to_party (generator);

CREATE TABLE hvdc_node_to_generator (node VARCHAR(30), generator VARCHAR(30));
LOAD DATA LOCAL INFILE 'c:\\mydir\\TPM\\Status_quo_HVDC\\node_to_generator.csv'
INTO TABLE hvdc_node_to_generator
COLUMNS TERMINATED BY ','
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;

CREATE INDEX idx ON hvdc_node_to_generator (node);

# checks
SELECT DISTINCT node FROM hvdc_node_to_generator WHERE NOT (node IN (SELECT node FROM gg_nodes)) AND NOT (node IN (SELECT node FROM load_nodes)); # should be none
SELECT DISTINCT generator FROM hvdc_node_to_generator WHERE NOT (generator IN (SELECT generator FROM hvdc_generator_to_party)); # should be none;
SELECT DISTINCT generator FROM hvdc_generator_to_party WHERE NOT (generator IN (SELECT generator FROM hvdc_node_to_generator)); # should be none;
