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.7.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.7-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for smartspread-1.0.7.tar.gz
Algorithm Hash digest
SHA256 a853abf963b8cbe121e7c0a2a2ff2e5777d94fe170362355c97cbe81f71d904c
MD5 08c9fad2cdd7b9fb8e28dea5069f5db6
BLAKE2b-256 3585856cd0eac3885fbef14040c30fa45774bd1392abae4eac1179c31b7f8be8

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for smartspread-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a4278ea47ce4debe172ffdb0c5b6af21c9c8000b5c7542f2474cbc24de5d8347
MD5 50a94eb6c68dbb0fbfc570f7b455f36c
BLAKE2b-256 22bb800ab17ec715cc3288e715171f3cfa0c6fda2b617277dfe0762042ad7047

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