Frictionless supports parsing Google Sheets data as a file format.
pip install frictionless[gsheets]
pip install 'frictionless[gsheets]' # for zsh shell
You can read from Google Sheets using Package/Resource
, for example:
from pprint import pprint
from frictionless import Resource
path='https://docs.google.com/spreadsheets/d/1mHIWnDvW9cALRMq9OdNfRwjAthCUFUOACPp0Lkyl7b4/edit?usp=sharing'
resource = Resource(path=path)
pprint(resource.read_rows())
[{'id': 1, 'name': 'english'}, {'id': 2, 'name': '中国人'}]
The same is actual for writing:
from frictionless import Resource, formats
control = formats.GsheetsControl(credentials=".google.json")
resource = Resource(path='data/table.csv')
resource.write("https://docs.google.com/spreadsheets/d/<id>/edit", control=control})
There is a dialect to configure how Frictionless read and write files in this format. For example:
from frictionless import Resource, formats
control = formats.GsheetsControl(credentials=".google.json")
resource = Resource(path='data/table.csv')
resource.write("https://docs.google.com/spreadsheets/d/<id>/edit", control=control)
Gsheets control representation. Control class to set params for Gsheets api.
(*, name: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, credentials: Optional[str] = None) -> None
API key to access google sheets.
Optional[str]