Skip to main content

A Python package for reading data from the Inputs, Assumptions and Scenarios Report (IASR) Microsoft Excel workbook published by the Australian Energy Market Operator for use in their Integrated System Plan modelling.

Project description

AEMO Integrated System Plan Assumptions Workbook Parser

PyPI version Continuous Integration and Deployment codecov pre-commit.ci status Rye

A Python package for reading data from the Inputs, Assumptions and Scenarios Report (IASR) Microsoft Excel workbook published by the Australian Energy Market Operator for use in their Integrated System Plan modelling.

Table of contents

How the package works

  1. Load a workbook using Parser (see examples below).
    • While we do not include workbooks with the package distribution, you can find the versions for which table configurations are written within workbooks/<version>.
  2. Table configuration files for data tables are located in src/config/<version>
    • These specify the name, location, columns and data range of tables to be extracted from a particular workbook version. Optionally, rows to skip and not read in can also be provided, e.g. where AEMO has formatted a row with a strike through to indicate that the data is no longer being used.
    • These are included with the package distributions.
  3. Parser loads the MS Excel workbook and, by default, will check if the version of the workbook is supported by seeing if configuration files are included in the package for that version.
  4. If they are, Parser can use these configuration files to parse the data tables and save them as CSVs.

[!NOTE] This package makes some opinionated decisions when processing tables with multiple header rows, including how tables are reduced to a single header and how data in merged cells is handled. For more detail, refer to the docstring and code in read_table.py.

Table configurations

Tables are defined in the configuration files using the following attributes:

  • name: the table name
  • sheet_name: the sheet where the table is located
    • N.B. there may be spaces at the end of sheet names in the workbook
  • header_rows: this specifies the row(s) with table column names
    • If there is a single row of table column names, then provide a single number (i.e. an int like 6)
    • If the table header is defined over multiple rows, then provide a list of row numbers sorted in ascending order (e.g. [6, 7, 8])
  • end_row: the last row of table data
  • column_range: the column range of the table in alphabetical/Excel format, e.g. "B:F"
  • skip_rows: optional, a list of excel rows in the table that should not be read in (e.g. [15])

Adding table configuration files to this package

Refer to the contributing instructions for details on how to contribute table configuration (YAML) files to this repository and package.

Examples

Bulk export

Export all the data tables the parser has a config file for to CSV files.

from isp_workbook_parser import Parser

workbook = Parser("<path/to/workbook>/2024-isp-inputs-and-assumptions-workbook.xlsx")

workbook.save_tables('<path/to/output directory>')

List tables with configuration files

Return a dict of table names, lists of tables names stored under a key which is their sheet name in the workbook Only tables the package has a configuration file for (for the given workbook version).

from isp_workbook_parser import Parser

workbook = Parser("<path/to/workbook>/2024-isp-inputs-and-assumptions-workbook.xlsx")

names = workbook.get_table_names()

names['Build limits']

Get table as DataFrame

Get a single table as a pandas DataFrame.

from isp_workbook_parser import Parser

workbook = Parser("<path/to/workbook>/2024-isp-inputs-and-assumptions-workbook.xlsx")

table = workbook.get_table("retirement_costs")

Get table with custom configuration

Get a table by directly providing the table config.

from isp_workbook_parser import Parser, TableConfig

workbook = Parser("<path/to/workbook>/2024-isp-inputs-and-assumptions-workbook.xlsx")

table_config = TableConfig(
  name="table_name",
  sheet_name="sheet_name",
  header_rows=5,
  end_row=21,
  column_range="B:J",
)

workbook.get_table_from_config(table_config)

Contributing

Interested in contributing to the source code or adding table configurations? Check out the contributing instructions, which also includes steps to install isp-workbook-parser for development.

Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

isp-workbook-parser was created as a part of the OpenISP project. It is licensed under the terms of GNU GPL-3.0-or-later licences.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

isp_workbook_parser-1.2.1.tar.gz (38.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

isp_workbook_parser-1.2.1-py3-none-any.whl (53.2 kB view details)

Uploaded Python 3

File details

Details for the file isp_workbook_parser-1.2.1.tar.gz.

File metadata

  • Download URL: isp_workbook_parser-1.2.1.tar.gz
  • Upload date:
  • Size: 38.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for isp_workbook_parser-1.2.1.tar.gz
Algorithm Hash digest
SHA256 83852ebf26dd99e3fd6c409c0ae7306061cb241cbbad1a9351973565f2a3cb53
MD5 1dc8cb2a85bfbae88f3e537708a5931d
BLAKE2b-256 1719e33bf30ae922010f83b2213c7846da1ef0035e7d6daafdec7fb0bc7c4b9f

See more details on using hashes here.

File details

Details for the file isp_workbook_parser-1.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for isp_workbook_parser-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 78c01d529b461654b8529c092f9137f5f0a92a6b99b4296e66716f7749ad6950
MD5 2fe51a070ce015afa82a2328d2f290c4
BLAKE2b-256 11273f0031255b7325961a112be02b07194a33fd0ca9466487cecc0859b0c8c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page