Skip to main content

A Python library that extends gspread for enhanced spreadsheet manipulation.

Project description

SmartSpread

SmartSpread is a Python library that extends gspread with advanced features for managing and manipulating Google Sheets. It offers a higher-level API for spreadsheet and tab operations, seamless integration with Pandas, and automation capabilities like background data syncing.

Features

  • Spreadsheet Management:

    • Create and retrieve spreadsheets with ease.
    • Grant access to collaborators programmatically.
  • Tab Operations:

    • Create, read, write, and update individual tabs.
    • Support for multiple data formats: DataFrame, list[dict], and list[list].
  • Automation:

    • Background writing to Google Sheets at regular intervals.
    • Efficient caching to minimize redundant API calls.
  • Pandas Integration:

    • Convert Google Sheets data to Pandas DataFrames and vice versa.
    • Seamless handling of numeric, string, and date formats.

Installation

Install the library using pip:

pip install smartspread

Getting Started

Authentication

  • Set up a Google Cloud Project and enable the Google Sheets API.
  • Create a service account and download the credentials JSON file.
  • Share your spreadsheet with the service account email.

Example Usage

Initialize a Spreadsheet

from smart_spread import SmartSpread

# Initialize SmartSpread with a Google Sheets ID and credentials file
spread = SmartSpread(
    sheet_identifier="your-spreadsheet-id-or-name",
    key_file="path/to/credentials.json"
)

Work with Tabs

# Get or create a tab
tab = spread.tab(tab_name="MyTab", data_format="DataFrame")

# Read data as a Pandas DataFrame
df = tab.read_data()
print(df)

# Update rows based on a column value
tab.update_row_by_column_pattern(
    column="Name",
    value="Alice",
    updates={"Age": 30, "City": "New York"}
)

# Write updated data back to the tab
tab.write_data(overwrite_tab=True)

Automate Background Writing

# Start background writing every 15 seconds
tab.start_background_write(interval=15, overwrite_tab=True)

# Stop background writing
tab.stop_background_write()

Documentation

Homepage: SmartSpread GitHub

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

smartspread-1.0.6.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

smartspread-1.0.6-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file smartspread-1.0.6.tar.gz.

File metadata

  • Download URL: smartspread-1.0.6.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for smartspread-1.0.6.tar.gz
Algorithm Hash digest
SHA256 d620202941fa6ca4a7d9f9dd025937506cf574aa06a7887d153b036eb9c4b089
MD5 60ab36c2edb1dfbea8b0ad038bc0a5df
BLAKE2b-256 17e08116dabe7fc40ab30fec062ad03e84ca1285a94373651ac9a2754abb5ee1

See more details on using hashes here.

File details

Details for the file smartspread-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: smartspread-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for smartspread-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ef58f8f26cca6ae667910ad944dfb5f8e9ab4630586371789bb118e9db4f6b18
MD5 49006c34b0f1d319e69e08cba6ee98cf
BLAKE2b-256 27a9cf59727526f1ccf62b5299396c26fc2b7495ec56f5ffc0aee0cdf99cd7bb

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