A Python package to load and manage Google Sheets or Excel file data.
Project description
Sheets Manager
Sheets Manager is a lightweight Python package designed for loading and managing data from Google Sheets, fetching data from all tabs within the file. This package provides a simple interface for accessing and storing tabular data in JSON format.
Features
- Load All Tabs: Fetch data from all tabs within a spreadsheet automatically.
- Easy to Use: Minimal setup to integrate into your projects.
- Lightweight: No unnecessary dependencies—uses only
pandasandjson.
Installation
You can install Sheets Manager via pip:
pip install sheetsmanager
Usage
Initializing the Manager
from sheetsmanager import SheetsManager
# Initialize the SheetsManager with your Google Sheet ID
sheet_id = "your_google_sheet_id"
SheetsManager.init(sheet_id)
The SheetsManager will automatically load all data from all tabs in the spreadsheet upon initialization. Note: The sheet_data and sheet_url variables are static, meaning they are shared across all instances of the SheetsManager class.
Accessing the Loaded Data
# Access the loaded data as a dictionary
print(SheetsManager.sheet_data) # Dictionary where keys are tab names and values are the tab data
Since sheet_data is a static variable, it will store the data globally, allowing all references to SheetsManager to access the same data.
Reloading the Data
If you want to reload the data from the Google Sheet and update all stored data, you can call the reload() method:
# Reload data from the spreadsheet
SheetsManager.reload()
This will refresh the sheet_data dictionary with the latest data from all tabs. The sheet_data variable is static, so any update will affect all instances that reference it.
Parameters
force_string (optional)
- Type:
bool - Default:
False - Description: Forces all values to be returned as strings when loading data. If
force_string=True, numerical values will be stored as strings.
Example Usage:
# Example usage with force_string
SheetsManager.init(sheet_id, force_string=True)
This ensures that all values remain in string format, which can be useful for preserving formatting from Google Sheets.
Getting the Sheet ID and Generating the URL
To use a Google Sheet with this package, you need the Sheet ID. Follow these steps:
Step 1: Open the Google Sheet
- Go to Google Sheets and open your spreadsheet.
Step 2: Retrieve the Sheet ID from the Publish to Web Dialog
- Click on
Filein the top menu. - Select
Share>Publish to the web. - In the dialog that opens, you will see the Sheet ID in the generated URL. It looks like this:
https://docs.google.com/spreadsheets/d/{SHEET_ID}/pub?output=xlsx - Copy the part between
/d/and/pub—this is your Sheet ID.
Step 3: Publish the Google Sheet
- In the same dialog, choose:
- Entire Document: To make all tabs available.
- Microsoft Excel (.xlsx) as the file format.
- Click
Publishand confirm your choice.
Important Warning
- Public Access: Publishing makes the spreadsheet accessible to anyone with the link.
- Read-Only: Others can download the file but cannot directly edit it.
Requirements
- Python 3.7+
- pandas
Contributing
Contributions are welcome! If you encounter bugs, have feature requests, or want to contribute code, feel free to submit issues and pull requests on GitHub.
License
Sheets Manager is licensed under the MIT License. See the LICENSE file for more 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
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 sheetsmanager-0.0.4.tar.gz.
File metadata
- Download URL: sheetsmanager-0.0.4.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2703fec5b5ebbde1fb4609496d75e832a72dc0d01831fa5c0422c92df568df56
|
|
| MD5 |
f7d5d0a44587825095766bfe3c85fcfb
|
|
| BLAKE2b-256 |
355d4054cb1cc16b5999ad8cfaa1ee61c59371b5930b8452ff2500bc25cc259f
|
File details
Details for the file sheetsmanager-0.0.4-py3-none-any.whl.
File metadata
- Download URL: sheetsmanager-0.0.4-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35ae7c8f00e5525858e59d72e9fe7654cc386b6875cbd4e9c95f82436f515db4
|
|
| MD5 |
c7074caec857d5ae927f61cc62f7e73b
|
|
| BLAKE2b-256 |
f35bbfdb6d46d08e7256a1de2791a35f7dc78b6deb2d35872b519071c90ac591
|