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], andlist[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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smartspread-1.0.5.tar.gz.
File metadata
- Download URL: smartspread-1.0.5.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c01026658d095496a9f21eaa7e1c99ffaaff46f90e3aea481048f65015bed5b3
|
|
| MD5 |
7384caab1584f919363efbc5e0094924
|
|
| BLAKE2b-256 |
718ad91db7164a97ba316715df3d772f162df0487140e6db8d010bd8a2f5354e
|
File details
Details for the file smartspread-1.0.5-py3-none-any.whl.
File metadata
- Download URL: smartspread-1.0.5-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e41ce2324ea34c8eb8079121935ba0e5dea4015fb11ddc7db94df24c43e649b
|
|
| MD5 |
0f5ce3d12cf4d3cdccbfe2832035d6f2
|
|
| BLAKE2b-256 |
ba86c5a322febf6c88aeb126ca89a493b76873a564d95b5fa75d8218f31b6a42
|