gsheet-api
Easily and efficiently manage a Google Sheet.
Install
pip install gsheet-api
Notes
- Credentials required are the Google Service account json file
- Sheet must be shared with edit access to the
client_emailfound the the service account - Credentials can be entered as a dictionary or a file path to a json file, both will work.
Usage Example
**Required arguments are defined in the "Available Methods" section
from gsheet_api import GSheetAPI
gsheet = GSheetAPI(**) # initialize the class
gsheet.sheet_to_df(**) # import data from the sheet to a Pandas DataFrame
gsheet.change_gsheet(**) # switch to a new Google Sheet to work off of
gsheet.get_cell(**) # get the contents of a single cell
gsheet.change_tab(**) # switch to a new tab in the current working Google Sheet
gsheet.set_cell(**) # set the value of a single cell
gsheet.df_to_sheet(**) # export a Pandas DataFrame to the current working sheet
gsheet.timestamp_to_cell(**) # export a timestamp to a single cell in the sheet
Available Methods
__init__(self, credentials, sheet_id, tab_name)
Initializes the GSheetAPI and sets the current working sheet and current working tab
:param dict|str credentials: Dictionary containing your Google Service Account json blob or a file
path entered as a string
:param str sheet_id: Sheet id found in the Google Sheet URL
:param str tab_name: Name of the tab to use within the Google Sheet
change_gsheet(self, sheet_id, tab_name)
Changes the current working sheet
:param str sheet_id: Sheet id found in the Google Sheet URL
:param str tab_name: Name of the tab to use within the Google Sheet
change_tab(self, tab_name)
Changes the working tab name within the current sheet
:param str tab_name: Name of the tab to use within the Google Sheet
df_to_sheet(self, df_input, row_start, col_start, clear_sheet=False, clear_range=None, allow_formulas=True,
include_index=False, resize=False, include_column_header=True)
Exports a Pandas DataFrame to a Google Sheet
:param pandas.DataFrame df_input: DataFrame to export
:param int row_start: Integer value of the row (starting at 1)
:param int col_start: Integer value of the column (starting at 1)
:param bool clear_sheet: (default False) If the entire sheet should be cleared before dumping data
:param bool clear_range: (default None) A range that should be cleared (eg. 'A1:B12')
:param bool allow_formulas: (default True) Whether or not formulas should be executed or shown as a raw string
:param bool include_index: (default False) Whether or not the DataFrame index should be shown in the sheet
:param bool resize: (default False) If the sheet should resize when the data is too large to fit in the sheet
:param bool include_column_header: (default True) If the data header should be dumped into the sheet
get_cell(self, cell)
Gets the current value of a given cell in the sheet
:param str cell: Cell reference (eg. 'A2')
:return: The current contents of the cell
set_cell(self, cell, cell_content)
Sets a cell to a given value
:param str cell: Cell reference (eg. 'A2')
:param str cell_content: Desired cell content
sheet_to_df(self, col_list, header, evaluate_formulas)
Grabs data from a Google Sheet and returns it as a Pandas DataFrame
:param list col_list: List of ints representing the column number to extract (eg. range(0, 4) for [0, 1, 2, 3])
:param int header: Integer of the row to use as a column (0 indexed)
:param bool evaluate_formulas: Whether or not the formulas should be computed before extracting the cell content
:return pandas.DataFrame: The sheet contents as a DataFrame object
timestamp_to_cell(self, cell, fmt='%Y-%m-%d %H:%M %Z', tz='US/Central')
Exports a timestamp to a single cell in the Google Sheet
:param str cell:
:param str fmt: (default "%Y-%m-%d %H:%M %Z")
:param str tz: (default "US/Central")
Metadata
Release files for gsheet-api 0.1.4
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_api-0.1.4.tar.gz | 4.1 kB | Without provenance | Details for gsheet_api-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gsheet_api-0.1.4-py3-none-any.whl | Python 3 | none | any | Details for gsheet_api-0.1.4-py3-none-any.whl |
Total release size: 10.0 kB
Release files / gsheet_api-0.1.4.tar.gz
| Download URL | gsheet_api-0.1.4.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d141f3546c2e704349a9265b3f58c06b3b84ce2cdb40180daf3324d34d69f2b4
|
|
BLAKE2b-256 checksum How to use checksums |
c789d17c45bd33225a755785579ac7a6ede6203442251a451f5382cef82900d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.4
|
Release files / gsheet_api-0.1.4-py3-none-any.whl
| Download URL | gsheet_api-0.1.4-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
22d5a736fed59fe3dbbc40518736f044cecc489c264bca9ce14568f0d09c0277
|
|
BLAKE2b-256 checksum How to use checksums |
9ac2b013750e19f94039bfa6fd42a2583659cbd26a10807b4dd8761d66d2a8c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.4
|
Security for gsheet-api 0.1.4
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.