Consuming Files in Python

Create Python-powered calculations

You can upload any file type to a CalcTree page and access it directly within your Python script. This is useful for referencing input datasets such as CSVs, DXF files, or configuration files.

Uploading Files (Learn more here)

To upload a file:

  1. Open the right-hand integrations panel on your CalcTree page

  2. Click + Add

  3. Select File Upload and select your file

  4. Once uploaded, the file will appear in the “Uploaded files” section

Accessing Files in Python

Uploaded files are accessible through the ct.page_files dictionary using the file name as the key. For example:

import pandas as pd

# Load a CSV file uploaded to the page
df = pd.read_csv(ct.page_files['my_input_data.csv'])

This pattern works for any file type compatible with your chosen Python libraries.

Use Cases

  • Load tabular data using pandas.read_csv()

  • Import geometric or CAD files (e.g. .dxf) using domain-specific libraries

  • Use in conjunction with plugins to automate processing of data files from ETABS etc. into reports in CalcTree

Notes

  • File names must match exactly (including extension)

  • Uploaded files are only available within the page they are uploaded to

  • Large files may increase processing time

Last updated