CalcTree Help Pages
  • What is CalcTree?
  • Getting started
    • CalcTree Pages
    • Create a CalcTree Page
    • Add a calculation
    • Collaborate with a colleague
  • Calculations
    • Parameters
      • Math formulas
        • Parameter Data Types
        • Native Functions
          • Arithmetic Functions
          • Trigonometric Functions
          • Logical & Comparison Functions
          • Matrix & Vector Functions
          • Probability & Combinatorics Functions
          • Statistical Functions
          • String Functions
          • Utility Functions
          • Other Native Functions
        • Valid Expression Syntax
      • Supported Units
      • Dropdown List Parameters
        • Linking CSV Data to Dependent Dropdowns in CalcTree
      • Parameter Settings
    • Integrations
      • Python in CalcTree
        • Adding a Python Source
        • Defining Parameters in Python
        • Referencing Other Parameters in Python
        • Working with Units in Python
        • Creating Tables and Visuals in Python
        • Consuming Files in Python
        • Using Pre-installed Python Libraries
      • Spreadsheets [Coming Soon!]
      • File Upload
        • CSV files
      • 3rd Party Software Plugins
        • Excel
        • Grasshopper
        • ETABS [v20 & v21]
        • ETABS [v22]
        • SAP 2000
        • CSI Bridge [v26]
    • Templates [Coming Soon!]
    • Optimising your calculations
  • Pages & Reports
    • CalcTree Documents
    • Static content
    • Parametric content
      • Parametric equation
      • Inputs
      • Outputs
  • Export to PDF
  • API
    • GraphQL API
      • Generating an API key
      • Queries
        • GetCalculation
        • Calculate
      • Examples
        • Bulk calculations with Python
  • Collaborate
    • Add members
    • Review and approval
    • Add stakeholders
  • Administrate
    • CalcTree Workspace
    • Versioning and Audit trail
  • CalcTree for System Administrators
Powered by GitBook
On this page
  • 1. Load and Structure Your Data
  • 2. Apply the Two-Step Filter
  • 3. Use the Selected Section in Your Logic
  • 4. Use the Selected Item in Your Logic
  • Summary
  1. Calculations
  2. Parameters
  3. Dropdown List Parameters

Linking CSV Data to Dependent Dropdowns in CalcTree

Learn how to connect a CSV file to dynamic, dependent dropdown parameters in CalcTree using Python for structured data filtering and selection.

PreviousDropdown List ParametersNextParameter Settings

Last updated 6 days ago

This guide walks you through how to read structured data from a CSV file and build dependent dropdowns in CalcTree using Python and page Parameters. The pattern is commonly used in workflows that require a selection of section or material type and then extracting specific properties for the selection for use in calculations.

1. Load and Structure Your Data

Upload your CSV file (e.g. CT - Standard Steel Section Capacity - DB.csv) using the Files tab, then read it into a structured format using pandas. Learn more .

Once this is complete, create a new code source, and add the below code.

import pandas as pd 

def read_csv(csv):
    return pd.read_csv(ct.page_files[csv])

section_db = read_csv("CT - Standard Steel Section Capacity - DB.csv") \
    .astype('object') \
    .fillna("") \
    .to_dict("records")

This loads your CSV into a list of dictionaries (records) that are easy to filter by field name.

In CalcTree, we recommend using Python dictionaries instead of pandas DataFrames for better performance. While DataFrames are supported, they are heavier and better suited to large-scale data processing outside of interactive calculation pages.

2. Apply the Two-Step Filter

2.1 Extract Primary Filter Options

In the same code source get the unique values from a primary column (e.g. "Type"):

type_list = list({row["Type"] for row in section_db})

2.2 Create page dropdown list

2.3 Filter the Secondary Options Based on type_list Selection

Filter the list of available "Section" values based on the currently selected "Section Type".

section_list = list({
    row["Section"] for row in section_db if row["Type"] == pg_type_list.upper()
})

Make sure the "Type" name matches the parameter name you set, in this case, pg_type_list .

2.4 Repeat step 2.2 for the new dependant list

3. Use the Selected Section in Your Logic

Once the user has made a selection, extract the full row from the database and use its fields in your calculation.

selected_row = next((row for row in section_db if row["Section"] == section_name), {})

depth = float(selected_row.get("Depth", 0))
area = float(selected_row.get("Area", 0))
moment_capacity = float(selected_row.get("M_ult", 0)) / 1000  # Nm → kNm

4. Use the Selected Item in Your Logic

Once a specific section is selected (e.g., "UB 203x102x23"), use it to retrieve or process further data in a Code Source 3.

Summary

This approach lets you:

  • Link a CSV database to interactive parameters

  • Build dependent dropdowns (e.g. section type → section name)

  • Extract and use structured data in calculations

It’s ideal for any workflow where selections narrow down from a database — like selecting standard parts, profiles, or material specs.

Under the code source in the RHS panel, navigate to the type_list parameter and insert to page. Then in the settings for this parameter, . Name your parameter something like pg_type_list .

Under the code source in the RHS panel, navigate to the section_list parameter and insert to page. Then in the settings for this parameter, . Name your parameter something like pg_type_list .

here
set the visibility to 'list'
set the visibility to 'list'