Skip to content

Commit

Permalink
include new data versions #14
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludee committed Jul 15, 2019
1 parent 58cc68c commit 8a44e94
Showing 1 changed file with 48 additions and 29 deletions.
77 changes: 48 additions & 29 deletions database_adapter/reeem_adapter_plexos.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,24 @@
from reeem_io import *

# input
filename = "2018-04-25_Base_Plexos_FrameworkV1_DataV2_Output.xlsx"
# filename = "2018-04-25_Base_Plexos_FrameworkV1_DataV2_Output.xlsx"
# filename = "2018-04-25_Base_Plexos_FrameworkV1_DataV2_Input.xlsx"
# filename = "2018-02-02_Base_Plexos_FrameworkV1_DataV1_Output.xlsx"
# filename = "2018-02-02_Base_Plexos_FrameworkV1_DataV1_Input.xlsx"
filenames = [
'2019-02-11_BaseIntegrated_Plexos_FrameworkV1_DataV1_Input.xlsx',
'2019-02-11_BaseIntegrated_Plexos_FrameworkV1_DataV1_Output.xlsx',
'2019-02-11_BaseIntegratedFixed_Plexos_FrameworkV1_DataV1_Input.xlsx',
'2019-02-11_BaseIntegratedFixed_Plexos_FrameworkV1_DataV1_Output.xlsx',
'2019-02-11_BaseIsolated_Plexos_FrameworkV1_DataV1_Input.xlsx',
'2019-02-11_BaseIsolated_Plexos_FrameworkV1_DataV1_Output.xlsx',
'2019-02-11_HighRESIntegrated_Plexos_FrameworkV1_DataV1_Input.xlsx',
'2019-02-11_HighRESIntegrated_Plexos_FrameworkV1_DataV1_Output.xlsx',
'2019-02-11_HighRESIntegratedFixed_Plexos_FrameworkV1_DataV1_Input.xlsx',
'2019-02-11_HighRESIntegratedFixed_Plexos_FrameworkV1_DataV1_Output.xlsx',
'2019-02-11_HighRESIsolated_Plexos_FrameworkV1_DataV1_Input.xlsx',
'2019-02-11_HighRESIsolated_Plexos_FrameworkV1_DataV1_Output.xlsx'
]

# regions = ['BG']
regions = ['BG', 'HR', 'HU', 'RO', 'SI']
Expand Down Expand Up @@ -167,41 +181,46 @@ def plexos_output_2_reeem_db(model, pathway, version, file_name, empty_rows, db_


if __name__ == '__main__':
# file and table
fns = reeem_filenamesplit(filename)

# i/o
if fns['io'] == "Input":
db_table = db_table_input
else:
db_table = db_table_output

# logging
log = logger()
start_time = time.time()
log.info('script started...')
log.info('...file: {}'.format(filename))
log.info('...pathway: {}'.format(fns['pathway']))
log.info('...model: {}'.format(fns['model']))
log.info('...framework: {}'.format(fns['framework']))
log.info('...version: {}'.format(fns['version']))
log.info('...i/o: {}'.format(fns['io']))
log.info('...regions: {}'.format(regions))
log.info('...database table: model_draft.{}'.format(db_table))
log.info('...establish database connection...')


# connection
log.info('...establish database connection:')
con = reeem_session()
log.info('...read file(s)...')

# import
for region in regions:
plexos_2_reeem_db(filename, fns, db_table, empty_rows,
db_schema, region, con)

# scenario log
scenario_log(con, 'REEEM', __version__, 'import', db_schema, db_table,
os.path.basename(__file__), filename)

# import files
for filename in filenames:

# file and table
fns = reeem_filenamesplit(filename)

# i/o
if fns['io'] == "Input":
db_table = db_table_input
else:
db_table = db_table_output

# log files
log.info('read file: {}'.format(filename))
log.info('...model: {}'.format(fns['model']))
log.info('...pathway: {}'.format(fns['pathway']))
log.info('...framework: {}'.format(fns['framework']))
log.info('...version: {}'.format(fns['version']))
log.info('...i/o: {}'.format(fns['io']))
log.info('...regions: {}'.format(regions))
log.info('...database table: model_draft.{}'.format(db_table))

# import
for region in regions:
plexos_2_reeem_db(filename, fns, db_table, empty_rows,
db_schema, region, con)

# scenario log
scenario_log(con, 'REEEM', __version__, 'import', db_schema, db_table,
os.path.basename(__file__), filename)

# close connection
con.close()
Expand Down

0 comments on commit 8a44e94

Please sign in to comment.