GSheetManager
GSheetManager is a Python package that provides a convenient interface for managing Google Sheets. It offers features like batch updates, local caching, and automatic worksheet refreshing to optimize interactions with Google Sheets.
Installation
You can install GSheetManager using pip:
pip install gsheet-manager
Requirements
- Python 3.6+
- gspread library
Usage
Here's a basic example of how to use GSheetManager:
from gsheet_manager import GSheetManager
class MySheetManager(GSheetManager):
@GSheetManager.batch_sync_with_remote
def update_sales_data(self, product, quantity, price):
# Find the row for the product
product_column = 0
quantity_column = 1
price_column = 2
total_column = 3
for row, row_data in enumerate(self.local_sheet_values):
if row_data[product_column] == product:
# Update quantity
self._set_buffer_cells(row, quantity_column, quantity)
# Update price
self._set_buffer_cells(row, price_column, price)
# Calculate and update total
total = quantity * price
self._set_buffer_cells(row, total_column, total)
print(f"Updated {product}: Quantity={quantity}, Price=${price}, Total=${total}")
return
# If product not found, add a new row
new_row = len(self.local_sheet_values)
self._set_buffer_cells(new_row, product_column, product)
self._set_buffer_cells(new_row, quantity_column, quantity)
self._set_buffer_cells(new_row, price_column, price)
self._set_buffer_cells(new_row, total_column, quantity * price)
print(f"Added new product {product}: Quantity={quantity}, Price=${price}, Total=${quantity * price}")
# Usage
manager = MySheetManager('path/to/key_file.json', 'Sales Sheet', 'Product Data')
manager.update_sales_data('Widget A', 100, 19.99)
manager.update_sales_data('Gadget B', 50, 24.99)
Features
- Batch updates to minimize API calls
- Local caching of sheet values
- Automatic worksheet refreshing
- Decorator for syncing operations with remote
API Reference
GSheetManager(key_file, doc_name, sheet_name)
Creates a new GSheetManager instance.
key_file: Path to your Google Service Account key filedoc_name: Name of your Google Sheetsheet_name: Name of the worksheet
Methods
refresh_worksheet(): Refreshes the worksheet if the timeout has passedsync_from_remote(): Syncs local values from the remote sheetbatch_update_remote(): Sends batched updates to the remote sheet_set_buffer_cells(python_row_idx, python_col_idx, value): Sets a value in the local buffer
Decorators
@batch_sync_with_remote: Decorator for methods that need to sync with the remote sheet
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for gsheet-manager 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gsheet_manager-0.4.0.tar.gz | 4.0 kB | Without provenance | Details for gsheet_manager-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gsheet_manager-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for gsheet_manager-0.4.0-py3-none-any.whl |
Total release size: 8.4 kB
Release files / gsheet_manager-0.4.0.tar.gz
| Download URL | gsheet_manager-0.4.0.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5206f21dfe3dad421a287579552e6e08c8bb9b9575f06fcf86e1a3f8d31d5837
|
|
BLAKE2b-256 checksum How to use checksums |
1f97e5a311c4826c2f9ff1d0c2b978342b7b85625cd926e76aadd4ebcd668bb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.8.17
|
Release files / gsheet_manager-0.4.0-py3-none-any.whl
| Download URL | gsheet_manager-0.4.0-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3038e1ef4311f673bc19434507c4dcc94ec1674915933c27630858a8e7d9cd18
|
|
BLAKE2b-256 checksum How to use checksums |
a396a3adbbbb3d52609ae0d2d695784b2dff2adc7e9dfe9ddaf65a2706164518
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.8.17
|
Security for gsheet-manager 0.4.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.