Skip to content

Python API — Excel Master Sheet

Use InputsFromExcelAdapter when you want to script the analysis in Python but still drive it from a completed master sheet.

The adapter reads every Section sheet from the master sheet, along with the factor cases, load cases, partial/combination factors and favourability settings — no manual configuration needed. RetainingWallAnalysis.run_cases() then runs every factor case × section × load case × combination case combination it finds.

Prerequisites

  • The package is installed inside an active virtual environment.
  • You have a completed master sheet, Template mastersheet REH.xlsx. If you don't have one yet, download the blank template and fill it in with your project's data.

Running all sections

python
from haskoning_retaining_wall.constants import Metric
from haskoning_retaining_wall.inputs import InputsFromExcelAdapter
from haskoning_retaining_wall.services import RetainingWallAnalysis

# 1. Load the master sheet once (all sections, factor cases and load cases are parsed)
adapter = InputsFromExcelAdapter(excel_path="Template mastersheet REH.xlsx")

print(f"Sections found:     {adapter.section_names}")   # e.g. ['Section A', 'Section B']
print(f"Factor cases found: {adapter.factor_cases}")

inputs = adapter.to_inputs()

analysis = RetainingWallAnalysis(
    metric=Metric.FOS,
    inputs=inputs,
    # project_name is optional — defaults to the master sheet's project name,
    # suffixed with the section name (e.g. "MyProject_Section")
)

analysis.run_cases()

Output files are written to an outputs/ folder relative to the current working directory (or to output_dir, if passed to RetainingWallAnalysis), in a sub-folder per section. Each case produces its own result workbook named <project_name>_<factor_case>_<load_case>_<combination_case>_Leading.xlsm, plus a Combined_Results.xlsx summary per section.

Running a single section

adapter.sections can be reassigned to restrict the run to one (or a subset of) sections:

python
adapter = InputsFromExcelAdapter(excel_path="Template mastersheet REH.xlsx")
adapter.sections = [adapter.sections[1]]   # run Section B only

inputs = adapter.to_inputs()

Overriding individual inputs

to_inputs() returns a plain, mutable RetainingWallInputs object — override any field on it (or on one of its sections) after building it, while everything else keeps its master-sheet value:

python
from haskoning_retaining_wall.domain.models import Friction

inputs = InputsFromExcelAdapter(excel_path="Template mastersheet REH.xlsx").to_inputs()

inputs.friction = Friction(block=0.55, foundation=0.65)
inputs.sections[0].water.landward = 1.5
inputs.sections[0].water.seaward = 0.5

Next steps