backbonetools.io#
Provids functionalities for processing both input and output files of backbone in python.
Functions
|
adds a parameter sheet from a dictionary of pandas dataframes to a GAMS database (necessary for conversion of frames dict to gdx file). |
|
adds a set sheet from a dictionary of pandas dataframes to a GAMS database (necessary for conversion of frames dict to gdx file). |
|
converts a directory of .csv files where each .csv filename corresponds to a sheet of the backbone input file to an excel input file |
|
converts a directory of .csv files where each .csv filename corresponds to a sheet of the backbone excel input file to a dictionary of pandas dataframes |
|
converts an excel file to a directory of .csv files where each .csv filename corresponds to a sheet of the backbone excel input file |
|
converts an backbone excel input file to a dictionary of pandas dataframes |
|
converts an excel file to a gdx file (both could be used as backbone inputs) |
|
Converts a dictionary of pandas dataframes where each entry corresponds to one sheet of the backbone input file to a directory of .csv files where each .csv filename corresponds to a sheet of the backbone input file |
|
Converts a dictionary of pandas dataframes where each entry corresponds to one sheet of the backbone input file to an backbone excel file |
|
Converts a dictionary of pandas dataframes where each entry corresponds to one sheet of the backbone input file to a backbone input gdx file |
- backbonetools.io.add_param_to_gdx_db(sheet_name, frames_dict, gams_db, debug=False)#
adds a parameter sheet from a dictionary of pandas dataframes to a GAMS database (necessary for conversion of frames dict to gdx file). Usually not called directly, but only used within other functions.
- Parameters:
sheet_name (str) – name of sheets
frame_dict (dict) – dictionary of pandas dataframes where each entry corresponds to one sheet of the backbone input file
gams_db (GAMSDatabse) – gams database to which sheet shall be added
debug (bool, optional) – Additional outputs for debugging. Defaults to False.
- Raises:
ValueError – raised, if sheet contains invalid values (e.g. strings where numbers are expected)
e – raised, if conversion fails for other reasons
- backbonetools.io.add_set_to_gdx_db(sheet_name, frames_dict, gams_db, debug=False)#
adds a set sheet from a dictionary of pandas dataframes to a GAMS database (necessary for conversion of frames dict to gdx file). Usually not called directly, but only used within other functions.
- Parameters:
sheet_name (str) – name of sheets
frame_dict (dict) – dictionary of pandas dataframes where each entry corresponds to one sheet of the backbone input file
gams_db (GAMSDatabse) – gams database to which sheet shall be added
debug (bool, optional) – Additional outputs for debugging. Defaults to False.
- Raises:
e – raised, if conversion fails
- backbonetools.io.csvs_to_excel(csv_dir, xl_path=None, overwrite=False)#
converts a directory of .csv files where each .csv filename corresponds to a sheet of the backbone input file to an excel input file
- backbonetools.io.csvs_to_frame_dict(csv_dir)#
converts a directory of .csv files where each .csv filename corresponds to a sheet of the backbone excel input file to a dictionary of pandas dataframes
- backbonetools.io.excel_to_csvs(xl_path, csv_dir_parent='backbone_input/versioned', overwrite=False)#
converts an excel file to a directory of .csv files where each .csv filename corresponds to a sheet of the backbone excel input file
- backbonetools.io.excel_to_frame_dict(xl_path)#
converts an backbone excel input file to a dictionary of pandas dataframes
- backbonetools.io.excel_to_gdx(xl_path, gdx_path=None)#
converts an excel file to a gdx file (both could be used as backbone inputs)
- backbonetools.io.frame_dict_to_csvs(frames_dict, csv_dir, overwrite=False)#
Converts a dictionary of pandas dataframes where each entry corresponds to one sheet of the backbone input file to a directory of .csv files where each .csv filename corresponds to a sheet of the backbone input file
- backbonetools.io.frame_dict_to_excel(frame_dict, xl_path)#
Converts a dictionary of pandas dataframes where each entry corresponds to one sheet of the backbone input file to an backbone excel file
- backbonetools.io.frame_dict_to_gdx(frames_dict, gdx_path, ws_dir=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/backbonetools/checkouts/latest/backbonetools'))#
Converts a dictionary of pandas dataframes where each entry corresponds to one sheet of the backbone input file to a backbone input gdx file
Modules
Functions for processing backbone input data |
|