Google Sheets
Fetch data from a sheet in google spreadsheet and get a data frame in your notebook.
Google Sheets: Free Online Spreadsheets for Personal Use

Pre-requisite: share your Google Sheet with our service account

For the driver to fetch the contents of your google sheet, you need to share it with the service account linked with Naas.
Now you can fetch data from the sheet as a pandas data frame.
Get your spreadsheetId for your spreadsheet URL like this :

Get

1
import naas_drivers
2
​
3
spreadsheet_id = "idd"
4
sheet_name = "sheet_name"
5
​
6
# Dataframe is returned
7
df = naas_drivers.gsheet.connect(spreadsheet_id).get(
8
sheet_name=sheet_name
9
)
Copied!

Send

Append

Append to the current sheet.
1
import naas_drivers
2
​
3
spreadsheet_id = "idd"
4
sheet_name = "sheet_name"
5
​
6
# Data accepts list of dict or dataframe
7
data = [{"name": "Jean", "email": "[email protected]"},
8
{"name": "Bunny", "email": "[email protected]"}]
9
​
10
naas_drivers.gsheet.connect(spreadsheet_id).send(
11
sheet_name=sheet_name,
12
data=data
13
)
Copied!

Erase and replace

When you need to clear the sheet before filling it!
1
import naas_drivers
2
​
3
spreadsheet_id = "idd"
4
sheet_name = "sheet_name"
5
​
6
# Data accepts list of dict or dataframe
7
data = [{"name": "Jean", "email": "[email protected]"},
8
{"name": "Bunny", "email": "[email protected]"}]
9
​
10
naas_drivers.gsheet.connect(spreadsheet_id).send(
11
sheet_name=sheet_name,
12
data=data,
13
append=False
14
)
Copied!

Delete

delete rows to the current sheet.
1
import naas_drivers
2
​
3
spreadsheet_id = "idd"
4
sheet_name = "sheet_name"
5
​
6
# Data accepts list of dict or dataframe
7
rows = [3, 4, 5]
8
​
9
naas_drivers.gsheet.connect(spreadsheet_id).delete(
10
sheet_name=sheet_name,
11
rows=rows
12
)
Copied!

Connect

You can also save your connection and don't repeat it for each method.
1
import naas_drivers
2
​
3
gsheet = naas_drivers.gsheet.connect("spreadsheet_id")
Copied!

Official documentation

GitHub - melalj/gsheet-api: Google Spreadsheet REST API Simplified (full CRUD)
GitHub