Skip to content

Commit

Permalink
Apply review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Lavigne <[email protected]>
  • Loading branch information
lavigne958 committed Oct 25, 2023
1 parent 056eb28 commit e132167
Showing 1 changed file with 42 additions and 46 deletions.
88 changes: 42 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,51 @@ Features:
- Sharing and access control.
- Batching updates.

## Installation

```sh
pip install gspread
```

Requirements: Python 3.6+.

## Basic Usage

1. [Create credentials in Google API Console](http://gspread.readthedocs.org/en/latest/oauth2.html)

2. Start using gspread:

```python
import gspread

gc = gspread.service_account()

# Open a sheet from a spreadsheet in one go
wks = gc.open("Where is the money Lebowski?").sheet1

# Update a range of cells using the top left corner address
wks.update('A1', [[1, 2], [3, 4]])

# Or update a single cell
wks.update('B42', "it's down there somewhere, let me take another look.")

# Format the header
wks.format('A1:B1', {'textFormat': {'bold': True}})
```

## v6.0.0 migration

### Silence the warnings
### Silence warnings

In version 5 there are many warnings to mark deprecated feature/functions/methods.
They can be silenced by setting the `GSPREAD_SILENCE_WARNINGS` environment variable to `1`

### HTTP Client

HTTP Clients have moved a dedicated file. GSpread uses by default the `HTTPClient`.
If you wish to use the new `BackoffHTTPClient` please update your code as follow:
HTTP Clients have moved to a dedicated file. by default, gspread uses the `HTTPClient`.
Also provided is a new `BackoffHTTPClient` , which retries failed requests with exponential time delay. It can be used with:

```pythong
```python
client = gspread.service_account(http_client=gspread.http_client.BackOffHTTPClient)
```

Expand All @@ -40,13 +72,11 @@ It works the same wayt for:
- `gspread.service_account_from_dict`
- `gspread.oauth_from_dict`

### Stop support for python-3.7

Python-3.7 is now end-of-life, GSpread stopped supporting it.
### python-3.7 end-of-life

Lowest supported python version: 3.8
spread v6 no longer supports Python 3.7. The lowest supported version is Python 3.8.

### Method signature changes
### `Worksheet.update` arguments have switched

The method ``Worksheet.update()`` has changed it's signature. The arguments ``range_name`` and ``values`` have swapped.

Expand All @@ -56,57 +86,23 @@ Please now use kwargs to assign arguments to be compatible with both v5.X.Y and
file.sheet1.update(range_name="I7", values=[["54"]])
```

#### Notice:
the argument `values` must be a 2D list.

the argument `values` must be a list of list !

### New tab color usage
### Colors now use hex representation

GSpread now uses hexadecimal value to color a tab.

You can use the utility function `gspread.utils.convert_colors_to_hex_value` to convert dict values to a single hexadecimal values.

The method ``gspread.Worksheet.update_tab_color()` accepts both dict and string values.

You can update you code as follow:
You can update you code as follows:

```python
tab_color = {"red": 1, "green": 0.1345, "blue": 1}
file.sheet1.update_tab_color(convert_colors_to_hex_value(**tab_color))
```

## Installation

```sh
pip install gspread
```

Requirements: Python 3.6+.

## Basic Usage

1. [Create credentials in Google API Console](http://gspread.readthedocs.org/en/latest/oauth2.html)

2. Start using gspread:

```python
import gspread

gc = gspread.service_account()

# Open a sheet from a spreadsheet in one go
wks = gc.open("Where is the money Lebowski?").sheet1

# Update a range of cells using the top left corner address
wks.update('A1', [[1, 2], [3, 4]])

# Or update a single cell
wks.update('B42', "it's down there somewhere, let me take another look.")

# Format the header
wks.format('A1:B1', {'textFormat': {'bold': True}})
```

## More Examples

### Opening a Spreadsheet
Expand Down

0 comments on commit e132167

Please sign in to comment.