| Name | SlySheets JSON |
| Version |
0.2.3
JSON |
| download |
| home_page | |
| Summary | No-boilerplate, async and typed Google Sheets access. |
| upload_time | 2023-08-15 02:10:34 |
| maintainer | |
| docs_url | None |
| author | Dunkyl 🔣🔣 |
| requires_python | >=3.10 |
| license | MIT License Copyright (c) 2021 dunkyl Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
#  SlySheets for Python
<!-- elevator begin -->
> 🚧 **This library is an early work in progress! Breaking changes may be frequent.**
> 🐍 For Python 3.10+
No-boilerplate, *async* and *typed* Google Sheets access. 😋
```shell
pip install slysheets
```
This library does not have full coverage.
Currently, the following topics are supported:
* Editing sheet cells
* Reading sheet metadata
You can use [SlyAPI](https://github.com/dunkyl/SlyPyAPI) to directly grant user tokens using the command line, covering the whole OAuth 2 user grant process after getting client credentials from [Google](https://console.cloud.google.com/).
<!-- elevator end -->
---
Example usage:
```py
import asyncio
from SlySheets import *
async def main():
auth = OAuth2('test/app.json', 'test/user.json')
spreadsheet = Spreadsheet(auth, '1arnulJxyi-I6LEeCPpEy6XE5V87UF54dUAo9F8fM5rw')
page = await spreadsheet.page('Sheet 1')
print(page.link())
# https://docs.google.com/spreadsheets/d/1arnulJxyi-I6LEeCPpEy6XE5V87UF54dUAo9F8fM5rw/edit#gid=0
# A1 notation
a1 = await page.cell('A1')
print(F"Cell A1: {a1}") # Cell A1: Foo
# zero-indexed rows
first_row = await page.row(0)
print(first_row)
print(F" | {first_row[0]:6} | {first_row[1]:6} |") # | Foo | Bar |
# header-indexed columns
foos = await page.column_named('Foo')
print(F"Foos: {foos}") # Foos: [1, 2, 3, 26]
# zero-indexed columns
foos_2 = await page.column(0)
assert foos == foos_2
for row in await page.rows_dicts(1, 4):
# index result by header
print(F" | {row['Foo']:6} | {row['Bar']:6} |") # | 1 | a | etc...
# append and extend, of course
await page.append([21, 'u'])
await page.append_dict({'Foo': 22, 'Bar': 'v'})
await page.extend([[23, 'w'], [24, 'x']])
await page.extend_dicts([{'Foo': 25, 'Bar': 'y'}, {'Foo': 26, 'Bar': 'z'}])
# TODO: consider not using slices to simplify
# await sheet.delete(slice(-2, None))
await page.delete_range('A6:B11')
# use spreadsheet object to update a specific page with A1 notation
await spreadsheet.set_cell("'Sheet 1'!E3", 'Hello World!')
# dates
today = await page.date_at_cell('D5') # =TODAY()
assert isinstance(today, datetime)
print(F"It is now {today.isoformat()} (timezone: {await spreadsheet.tz()})")
# batch edits
async with page.batch() as batch:
batch.set_range("C2:D3", [[0, 1], [2, 3]])
asyncio.run(main())
```
---
Example CLI usage for getting authorized:
```sh
# WINDOWS
py -m SlySheets grant
# MacOS or Linux
python3 -m SlySheets grant
```
Granting credentials requires a Google Cloud Console account and JSON file.
Please see https://docs.dunkyl.net/SlyAPI-Python/tutorial/oauth2.html for more information.
Raw data
{
"_id": null,
"home_page": "",
"name": "SlySheets",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "",
"author": "Dunkyl \ud83d\udd23\ud83d\udd23",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/51/63/d580dde08f0a48f035188f978b482d4964decd1f1dc10060c0b315229d4e/SlySheets-0.2.3.tar.gz",
"platform": null,
"description": "#  SlySheets for Python\r\n\r\n<!-- elevator begin -->\r\n\r\n> \ud83d\udea7 **This library is an early work in progress! Breaking changes may be frequent.**\r\n\r\n> \ud83d\udc0d For Python 3.10+\r\n\r\nNo-boilerplate, *async* and *typed* Google Sheets access. \ud83d\ude0b\r\n\r\n```shell\r\npip install slysheets\r\n```\r\n\r\nThis library does not have full coverage.\r\nCurrently, the following topics are supported:\r\n\r\n* Editing sheet cells\r\n* Reading sheet metadata\r\n\r\nYou can use [SlyAPI](https://github.com/dunkyl/SlyPyAPI) to directly grant user tokens using the command line, covering the whole OAuth 2 user grant process after getting client credentials from [Google](https://console.cloud.google.com/).\r\n\r\n<!-- elevator end -->\r\n\r\n---\r\n\r\nExample usage:\r\n\r\n```py\r\nimport asyncio\r\nfrom SlySheets import *\r\n\r\nasync def main():\r\n\r\n auth = OAuth2('test/app.json', 'test/user.json')\r\n\r\n spreadsheet = Spreadsheet(auth, '1arnulJxyi-I6LEeCPpEy6XE5V87UF54dUAo9F8fM5rw')\r\n page = await spreadsheet.page('Sheet 1')\r\n\r\n print(page.link())\r\n # https://docs.google.com/spreadsheets/d/1arnulJxyi-I6LEeCPpEy6XE5V87UF54dUAo9F8fM5rw/edit#gid=0\r\n\r\n # A1 notation\r\n a1 = await page.cell('A1')\r\n print(F\"Cell A1: {a1}\") # Cell A1: Foo\r\n\r\n # zero-indexed rows\r\n first_row = await page.row(0)\r\n print(first_row)\r\n print(F\" | {first_row[0]:6} | {first_row[1]:6} |\") # | Foo | Bar |\r\n\r\n # header-indexed columns\r\n foos = await page.column_named('Foo')\r\n print(F\"Foos: {foos}\") # Foos: [1, 2, 3, 26]\r\n\r\n # zero-indexed columns\r\n foos_2 = await page.column(0)\r\n assert foos == foos_2\r\n\r\n for row in await page.rows_dicts(1, 4):\r\n # index result by header\r\n print(F\" | {row['Foo']:6} | {row['Bar']:6} |\") # | 1 | a | etc...\r\n\r\n # append and extend, of course\r\n await page.append([21, 'u'])\r\n await page.append_dict({'Foo': 22, 'Bar': 'v'})\r\n\r\n await page.extend([[23, 'w'], [24, 'x']])\r\n await page.extend_dicts([{'Foo': 25, 'Bar': 'y'}, {'Foo': 26, 'Bar': 'z'}])\r\n\r\n # TODO: consider not using slices to simplify \r\n # await sheet.delete(slice(-2, None))\r\n await page.delete_range('A6:B11')\r\n\r\n # use spreadsheet object to update a specific page with A1 notation\r\n await spreadsheet.set_cell(\"'Sheet 1'!E3\", 'Hello World!')\r\n\r\n # dates\r\n today = await page.date_at_cell('D5') # =TODAY()\r\n assert isinstance(today, datetime)\r\n print(F\"It is now {today.isoformat()} (timezone: {await spreadsheet.tz()})\")\r\n\r\n # batch edits\r\n async with page.batch() as batch:\r\n batch.set_range(\"C2:D3\", [[0, 1], [2, 3]])\r\n\r\nasyncio.run(main())\r\n```\r\n\r\n---\r\n\r\nExample CLI usage for getting authorized:\r\n\r\n```sh\r\n# WINDOWS\r\npy -m SlySheets grant\r\n# MacOS or Linux\r\npython3 -m SlySheets grant\r\n```\r\n\r\nGranting credentials requires a Google Cloud Console account and JSON file.\r\nPlease see https://docs.dunkyl.net/SlyAPI-Python/tutorial/oauth2.html for more information.\r\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2021 dunkyl Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "No-boilerplate, async and typed Google Sheets access.",
"version": "0.2.3",
"project_urls": {
"Bug Tracker": "https://github.com/dunkyl/SlySheets-Python/issues",
"Documentation": "https://docs.dunkyl.net/SlySheets-Python/",
"Homepage": "https://docs.dunkyl.net/SlySheets-Python/",
"Repository": "https://github.com/dunkyl/SlySheets-Python"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "16e01d710566d0e454c683fedeef73c3bdf713c719cd88459bc3e59b4b1e4de6",
"md5": "3de31a602f926823cbfb26e3b1fcb89b",
"sha256": "efe550f9d5382c4129ef6d37e5bb5c6678010c80f0778bcfe1d93960dc72e916"
},
"downloads": -1,
"filename": "SlySheets-0.2.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3de31a602f926823cbfb26e3b1fcb89b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 9145,
"upload_time": "2023-08-15T02:10:32",
"upload_time_iso_8601": "2023-08-15T02:10:32.609185Z",
"url": "https://files.pythonhosted.org/packages/16/e0/1d710566d0e454c683fedeef73c3bdf713c719cd88459bc3e59b4b1e4de6/SlySheets-0.2.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5163d580dde08f0a48f035188f978b482d4964decd1f1dc10060c0b315229d4e",
"md5": "2e8aa2e2f0bba1ee54635566b07accae",
"sha256": "bbe62afdf8dcdaf37c8cd6b03cc3b1738b04f907367d735bee1bac57247d49ce"
},
"downloads": -1,
"filename": "SlySheets-0.2.3.tar.gz",
"has_sig": false,
"md5_digest": "2e8aa2e2f0bba1ee54635566b07accae",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 10376,
"upload_time": "2023-08-15T02:10:34",
"upload_time_iso_8601": "2023-08-15T02:10:34.127046Z",
"url": "https://files.pythonhosted.org/packages/51/63/d580dde08f0a48f035188f978b482d4964decd1f1dc10060c0b315229d4e/SlySheets-0.2.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-15 02:10:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dunkyl",
"github_project": "SlySheets-Python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "slysheets"
}