Closed pabloazurduy closed 1 month ago
Hi thank you for this feature request. It's very interesting! I never thought of it !
Could you please confirm if I get your code correctly?
I understand your function:
Right ?
If so, it could be improved yes, and possibly the API has ways to help, or at least we could play with the API and the coordinates system as it can in some scenarios return a matrix of all values only, so it's then easy to compute the furthest value has at least or direction (bottom or right) is already given by the API
We can take a look at it, we have a few things to work on first then, if it's easy it could land in 6.1.0 if not then it's gonna be in the next version after that (at least 6.2.0)
hi @lavigne958 , I edited the post because it wasn't very clear, my apologies.
I added a snippet with a rudimentary implementation of the expand("table")
case.
however, it has some flaws:
rowcol_to_a1
transformation seems unnecessary, converting row and column numbers to text maybe its not necessary. Would it be better to return a CellRange
? (or an equivalent object ?)also, I'm not very familiar with the modules, but if you guide me on this I might be able to do a PR ? let me know :) thanks in advance
Hi. I find images the most helpful.
Is this what you mean?
Hi. I find images the most helpful.
Is this what you mean?
[image]
yess, exactly that
cool :)
it sounds like it could be a useful function.
Since it is unknown, it would involve getting the whole sheet, down and right, starting from cell
.
Is there a way to get this in gspread currently?
If so, we could add a "table
" function to utils
, which could be used something like
all_cells = worksheet.get()
table = utils.find_table(all_cells)
I think that would be nice as this feature does not require extra requests, but only formatting of data we can get by existing means.
Are you interested in trying to make a PR? We can help if so :)
cool :)
it sounds like it could be a useful function.
Agreed 🙃
Since it is unknown, it would involve getting the whole sheet, down and right, starting from
cell
.Is there a way to get this in gspread currently?
I think, if you request an unbounded range from that cell, the API will return everything down from that point. Then all we need is to square it and remove everything after the first whitespace. 🤔
alright ! we made it ! next release will contain the new feature.
In the past, I used to use xlwings library for Excel. In their API they have a very handy way of selecting "tables" starting for a specific cell.
you could use it, for example, to get data from a series of sheets that have table with variable size but always start from the cell
"A1"
. so you "expand" the selection similar to what you do when docmd+left_arrow
,cmd+down_arrow
on the worksheet,The usage is better explained in the documentation:
range.expand('table')
this is a snippet of the usage, expand have one of three arguments
"table", "right","down"
.I implemented the
"table"
version for myself just because I found it very handy.maybe there's a way of doing this using
gspread
, but I couldn't find it.Thanks in advance!