Skip to main content
Yanked

This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Reason given by maintainers: temporarily revoking release, pending release approval

Smartsheet Engine

A Python library that simplifies Smartsheet API workflows

Smartsheet Engine lets you perform high-level actions on a Smartsheet, such as updating rows or locking a column, using only one function call. And it represents Smartsheets as dataframes, so it can be seamlessly integrated into existing workflows that use dataframes.

Table of Contents

Features

Current

  • Create, Read, Update, and Delete Smartsheet Data
    • Get a Smartsheet as a Dataframe
    • Append a Dataframe to a Smartsheet
    • Update a Smartsheet From a Dataframe
    • Delete Smartsheet Rows
  • Modify Smartsheet Object Properties
    • Set Column Formula
    • Set Column Dropdown Options
    • Lock or Unlock a Column
    • Hide or Unhide a Column
    • Share a Smartsheet

Coming Soon

  • Create, Read, Update, and Delete Smartsheet Data
    • Provision a Smartsheet
      • Create a Smartsheet From a Schema
      • Create a Column
  • Analyze Smartsheet Dataframes
    • Compare Two Dataframes and Identify Row Changes
    • Compare Two Dataframes and Identify Column Changes
    • Compare Two Dataframes and Identify Cell Value Changes
  • Modify Smartsheet Object Properties
    • Set Column Formatting
    • Change a Shared User's Access Level
  • Other
    • Command-Line Interface

Roadmap

See the roadmap for the master list of work to be done and features coming soon

Installation

  1. Download and install Python if needed
  2. Install smartsheet-engine

From PyPI

pip install smartsheet-engine

From GitHub

git clone https://github.com/1npo/smartsheet-engine.git
cd smartsheet-engine
pip install .

From the Alteryx Python Tool

Alteryx.installPackage(package="smartsheet-engine")

Usage

To use smartsheet-engine in your script, Python Tool, or Notebook:

  1. Get your Smartsheet API key and save it to a variable, such as smartsheet_api_key
  2. Import the SmartsheetEngine class, and start a SmartsheetEngine with your API key:
from smartsheet_engine import SmartsheetEngine

S = SmartsheetEngine(api_key=smartsheet_api_key)
  1. Use the engine as needed in your workflow (see How-To Guides for examples)

How-to Guides

Create, Read, Update, and Delete Smartsheet Data

Get a Smartsheet as a Dataframe

# Gets the dataframe for the Smartsheet called `finished_test_grid`
# and prints the dataframe

df = S.get_sheet('finished_test_grid').sheet_df
print(df)
         _ss_row_id  number   rating
0   123734752464772     1.0   Lowest
1  7876435046272900     2.0      Low
2  2246935512059780     3.0   Medium
3  2463203892629380     4.0     High
4  6966803519999876     5.0  Highest

Append a Dataframe to a Smartsheet

# Appends 2 rows from a dataframe to the Smartsheet named `test_grid`

df = pd.DataFrame({
    'number':       [4, 5],
    'rating':       [None, None],
    'missing_col':  ['data', 'ignored'], })

S.append_sheet_rows('test_grid', df)
Before Appending After Appending
Before appending rows After appending rows

Update a Smartsheet From a Dataframe

# Gets the dataframe for the Smartsheet named `test_grid`, changes the
# dropdown options for the `rating` column, and then updates the column

import numpy as np

df = S.get_sheet('test_grid').sheet_df

S.update_column_dropdown('test_grid', 'rating', ['Lowest', 'Low', 'Medium', 'High', 'Highest'])

conditions = [
    df['number'] == 1,
    df['number'] == 2,
    df['number'] == 3,
    df['number'] == 4,
    df['number'] == 5,
]
choices = [
    'Lowest',
    'Low',
    'Medium',
    'High',
    'Highest',
]
df['rating'] = np.select(conditions, choices)

S.update_sheet_rows('test_grid', df)
Before Updating After Updating
Before updating rows After updating rows

Delete Smartsheet Rows

# Gets the dataframe for the Smartshet named `test_grid`, selects
# only the rows that have the number 2 or 3 in the number column,
# and then deletes them

df = S.get_sheet('test_grid').sheet_df

df = df[df['number'].isin([2,3])]

S.delete_sheet_rows('test_grid', df)
Before Deleting After Deleting
Before deleting rows After deleting rows

Provision a Smartsheet

Analyze Smartsheet Data

Compare Two Dataframes and Identify Row Changes

Compare Two Dataframes and Identify Column Changes

Compare Two Dataframes and Identify Cell Value Changes

Modify Smartsheet Object Properties

Set Column Formula

# Changes the column formula for the `month_rated` column to "=MONTH([date_rated]@row)"
# on the Smartsheet named `test_grid`.

S.set_column_formula('test_grid', 'month_rated', '=MONTH([date_rated]@row)')

Set Column Dropdown Options

# Changes the dropdown options for the `rating` column to `Low, Medium, and High` on the
# Smartsheet named `test_grid`, and restricts the column to only allow these values

S.set_column_dropdown('test_grid', 'rating', ['Low', 'Medium', 'High'], restrict_values=True)

Set Column Formatting

Lock or Unlock a Column

# Locks and then unlock the `rating` column on the Smartsheet
# named `test_grid`

S.lock_column('test_grid', 'rating')
S.unlock_column('test_grid', 'rating')

Hide or Unhide a Column

# Hide and then unhide the `rating` column on the Smartsheet
# named `test_grid`

S.hide_column('test_grid', 'rating')
S.unhide_column('test_grid', 'rating')

Share a Smartsheet

# Share a Smartsheet named `test_grid` with a list of email addresses, giving
# those users the EDITOR_SHARE access level, and send them an email notification
# that the sheet has been shared with them

S.share_sheet('test_grid',
              ['alice@acme.com', 'bob@acme.com'],
              'EDITOR_SHARE',
              send_email=True)

Update a Shared User's Sheet Permissions

Developer's Guide

API Reference

System Design

Architecture Diagram

smartsheet-engine system architecture diagram

SmartsheetEngine Class

Provides a set of high-level Smartsheet actions, such as appending dataframe rows to a Smartsheet or locking a column

  • Uses the SmartsheetAPIClient class to interact with the Smartsheet API
  • Uses the GridRepository class to manage the Smartsheet SDK Sheet objects that represent all the Smartsheets that are available to the user

SmartsheetAPIClient Class

Simplifies using Smartsheet's Python SDK

  • Converts dataframes to lists of Smartsheet SDK Row, Column, and Cell objects, and vice-versa
  • Sends the lists of SDK objects to the API
  • Retrieves data from the API and returns it to the user

GridRepository Class

Stores, retrieves, and modifies SmartsheetGrid objects

  • Simple in-memory repository
  • Stores SmartsheetGrids in a list
  • Can create, read, and update SmartsheetGrid objects

SmartsheetGrid Dataclass

Contains a Smartsheet Sheet object, relevant metadata, and a dataframe representation of the Sheet

  • Sheet Name, ID, and user's access level
  • Column map (between English column name and Smartsheet Column ID)
  • The Smartsheet SDK Sheet object
  • The pandas dataframe representation of the Sheet
  • Created and modified timestamps
  • Flags for whether or not the Sheet exists in a folder or a workspace
  • Name and ID of the folder or workspace

Testing

Current Coverage

Name Stmts Miss Cover Missing
smartsheet_engine/__init__.py 206 22 89% 125-126, 133-138, 162-168, 214-218, 228, 650, 722-726, 738, 751
smartsheet_engine/client.py 188 23 88% 97-100, 126, 147-155, 342, 344, 346, 399, 401, 403, 405, 412, 420, 460-463
smartsheet_engine/grids.py 98 23 77% 207-226, 241-252
smartsheet_engine/utils.py 18 1 94% 49
tests/test_client.py 218 0 100%
tests/test_data.py 86 0 100%
tests/test_grids.py 90 0 100%
tests/test_smartsheet_engine.py 210 0 100%
tests/test_utils.py 17 0 100%
TOTAL 1131 69 94%

How to Run the Tests and Generate the Report

To run the tests and generate the coverage reports:

  1. Install pytest and coverage: pip install pytest coverage
  2. Change directory to the smartsheet-engine project root
  3. Run the tests: coverage run -m pytest
  4. Generate the Markdown report: coverage report -m --format=markdown
  5. Generate the HTML report: coverage html -d docs/test_coverage_html

Linting

Current Results

How to Run the Linter and Generate the Report

See pylint_results_170b34a.log for the current Pylint results.

To generate the report:

  1. Install pylint: pip install pylint
  2. Change directory to the smartsheet-engine project root
  3. Run Pylint: pylint -d W0311 smartsheet_engine > docs/linting/pylint_results_{commit}.log

Acknowledgements

  • The architecture diagram was made with Lucidchart

License

This library was created by Nick O'Malley and is currently unlicensed.

Contributing

See CONTRIBUTING.md for instructions on how to contribute to smartsheet-engine

Metadata

Release files for smartsheet-engine 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smartsheet-engine 1.5.0
File Size Uploaded Provenance Actions
smartsheet_engine-1.5.0.tar.gz 30.4 kB Without provenance Details for smartsheet_engine-1.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for smartsheet-engine 1.5.0
File Interpreter ABI Platform Actions
smartsheet_engine-1.5.0-py3-none-any.whl Python 3 none any Details for smartsheet_engine-1.5.0-py3-none-any.whl

Total release size: 59.2 kB

Release files / smartsheet_engine-1.5.0.tar.gz

Download URL smartsheet_engine-1.5.0.tar.gz
Size 30.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f62939a322f182d75527fba04dbbf088dae86f39376e737c275cefcfcab0fbd5
BLAKE2b-256 checksum
How to use checksums
efcd60826f3cd616f93222555398019d97172fa784d16ec9b875b12e59f9423c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / smartsheet_engine-1.5.0-py3-none-any.whl

Download URL smartsheet_engine-1.5.0-py3-none-any.whl
Size 28.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8de0450a00672118578b5c9dcbf75ab170fdc033fb4978f63ea3f6fce91d2273
BLAKE2b-256 checksum
How to use checksums
d4b6b716d2e2e00e7a515d86b258c571f266877bd5c2b396370f1e95b74d4b85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Security for smartsheet-engine 1.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.5.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page