-
Notifications
You must be signed in to change notification settings - Fork 952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
size of range returned by get and get_values can be smaller than the input size #1289
Comments
Thinking about it, if the user does not know the size of the region they request (cases 2,3,4,7,8 above) then they cannot complain when we return the "wrong" size region. This is only not the case for named ranges, which have a defined size when you create them. |
Can we not query the sheet's size? |
Re: my comment in #1284 as well as your statement above: should the default behavior not be to maintain the shape, given that the region is specified? As in: First instinct would be to parse the A1 notation for 2x characters and 2x integers (post |
I agree with what is said here.
We can, and we do. We store this as properties in the worksheet object. Lines 173 to 181 in 817ebb8
I too believe this should be the default. See this table for the ways (I believe) a user can use
✅ - columns and rows are explicit in the notation However, it is a known issue that the For now, I suggest we implement padding with For this, we simply need a regex match which can determine between cases 1 and 5, and the rest, and then to apply the logic stated in the instructions above. We already use regex in a similar way in the module: Lines 25 to 26 in 817ebb8
I suggest something like |
Technically, the (unexpected) behaviour is in the documentation for However, it is still unexpected. I will continue my work. |
Worksheet.get
andWorksheet.get_values
return a smaller area than asked for if some of it is empty. For example, see this call of `worksheet.get("E7:I11")Replication
expected output (size 5 x 5)
actual output (size 4 x 4)
Related issues
#910, #947, #1284
Attempted fixes
#985, #1281
steps to fix
Worksheet.get
andWorksheet.get_values
, something likemaintain_size
maintain_size
is truerange_name
usinga1_to_rowcol
utils.fill_gaps
to fill the empty values and return thisWorksheetTest.test_get_values_and_maintain_size
Problems
There are many ways to define a range with Google Sheets. See the documentation for a1 notation. Here is a summary. In green are the ranges we can know the size of. In red the ones we can't.
What we could do is resize the data if the size is knowable (cases 1 and 5 above) and leave it as-is if not (cases 2, 3, 4, 6, 7, 8 above).
Questions
Should this be the default behaviour?
The text was updated successfully, but these errors were encountered: