burnash / gspread

Google Sheets Python API

Home Page:https://docs.gspread.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

get_all_records retrieves a large number of empty rows after the end of the data

timmc-edx opened this issue · comments

Describe the bug

A call to get_all_records retrieves the desired data, but also returns a large number of rows from below the data.

This is new with 5.12.2, and did not occur in 5.12.1.

To Reproduce

Data:

aaa bbb
w x
y z

Running worksheet.get_all_records(expected_headers=['aaa']) prints the following:

{'aaa': 'w', 'bbb': 'x'}
{'aaa': 'y', 'bbb': 'z'}
{'aaa': '', 'bbb': ''}
{'aaa': '', 'bbb': ''}
{'aaa': '', 'bbb': ''}
{'aaa': '', 'bbb': ''}
...993 more empty rows...

(On a larger spreadsheet, there were only about 8 of these trailing empty rows.)

Expected behavior

Only two rows should have been returned.

Environment info:

  • Operating System: Debian Linux
  • Python version: 3.8
  • gspread version: 5.12.2

the height of a spreadsheet created on Google Sheets is by default 100.

In our tests we have to set the height. So, we did not catch this case.

get_all_records has become a bit of a mess of a method...

anyway I have made a fix with #1364 which will come in minor release 5.12.3

Yes, that does appear to fix it!

Hi. Please read the proposal for changing how get_all_records works for next release 6.0.0 -> #1367. We would enjoy if you would contribute your opinion :)