Skip to content

Commit

Permalink
briefen migration guide readme
Browse files Browse the repository at this point in the history
  • Loading branch information
alifeee committed Jan 20, 2024
1 parent de307cb commit 8465fce
Showing 1 changed file with 9 additions and 30 deletions.
39 changes: 9 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,41 +88,20 @@ file.sheet1.update_tab_color(tab_color)
+ age = spreadsheet.get_lastUpdateTime()
```

### Removed method `Worksheet.get_records`
### Replace method `Worksheet.get_records`

The method `Worksheet.get_records()` has been removed.
The function `utils.to_records` has been added.

It takes hearder row, a matrix values and build the records from them.

### Simplify method `Worksheet.get_all_records`

v6 simplified the method `Worksheet.get_all_records`, it does not accept a bounded ranges of rows for
the values to fill the records. The below arguments have been remove from the method signature:

- first_index
- last_index

It now uses the function `utils.to_records`.

Update the method signature as follow:
In v6 you can now only get *all* sheet records, using `Worksheet.get_all_records()`. The method `Worksheet.get_records()` has been removed. You can get some records using your own fetches and combine them with `gspread.utils.to_records()`.

```diff
get_all_records(
empty2zero=False,
head=1,
- first_index=None,
- last_index=None,
default_blank="",
allow_underscores_in_numeric_literals=False,
numericise_ignore=[],
value_render_option=None,
expected_headers=None,
)
+ from gspread import utils
all_records = spreadsheet.get_all_records(head=1)
- some_records = spreadsheet.get_all_records(head=1, first_index=6, last_index=9)
- some_records = spreadsheet.get_records(head=1, first_index=6, last_index=9)
+ header = spreadsheet.get("1:1")[0]
+ cells = spreadsheet.get("6:9")
+ some_records = utils.to_records(header, cells)
```

In order to achieve the previous behavior one case use the new function `utils.to_records` by manually providing the headers and the values.

### Silence warnings

In version 5 there are many warnings to mark deprecated feature/functions/methods.
Expand Down

0 comments on commit 8465fce

Please sign in to comment.