-
Notifications
You must be signed in to change notification settings - Fork 950
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
feature -- adding worksheet.get_records
to get specific row ranges
#1301
feature -- adding worksheet.get_records
to get specific row ranges
#1301
Conversation
worksheet.get_records_subset
to get specific row ranges
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR! You have put a lot of work into it! :)
Some questions from me:
- Why update all the cassettes? You should only need to update the ones for the tests you modify/add
- The new function should be named
get_records
, as this is simpler - The first_row and last_row (any maybe head?) should be required arguments
- We do not need the methods
_validate_rows_ranges_for_get_records_subset
_validate_headers_and_keys_for_get_records_subet
_pad_values_and_keys_for_get_records_subset
. This logic can go in the functionget_records
Some thoughts:
- instead of "first_row" and "last_row", we could instead ask for a
range
(user would enter "4:9", for example. This would then make it easier to translate the function to be column-based instead of row-based (see getallrecords() – can there be a "rows" option to get attributes from rows, not columns? #808)
Thanks again for this work :)
I've made a few changes, please check and let me know what you think about the current state. Also, I'm not sure how replacing first and last_row with a range would help implement #808. I'd actually argue for renaming |
Thanks! Your code changes are very clear, and your tests are layed out very clearly. It is good.
This sounds good. My original thinking was that a user could select a range with "4:8" or "D:G", as one could use as indices in I will enable the workflow now. You may need to run the formatter with |
Cassettes are broken. I have fixed them in https://github.com/burnash/gspread/tree/feature/get_records_limit I could not push to https://github.com/AndrewBasem1/gspread/tree/feature/get_records_limit |
Moved the `first_row` and `last_row` validations inside the method, as well as the `expected_headers` and `keys` validations.
Once this is done, and the CI passes, I think this is ready to merge :) |
You will want to delete the cassette for |
@alifeee you'll have to excuse my lack of expertise, it's my first time working with cassettes so I don't have a full understanding of them. hope this fixed the issue. Please check and let me know if there is anything else I can do |
worksheet.get_records_subset
to get specific row rangesworksheet.get_records
to get specific row ranges
Thanks again for this PR!! You have been clear, helpful, and thoughtful about your changes. You write Python well. I am happy to merge this in. It will be usable in the next release of gspread, which should be v5.12.0 in a couple of weeks (see milestone) |
Closes #1294
Changes
get_records_subset
to provide similar behavior toget_all_records
but allows the user to chose a first_row and last_row to get the data from only.get_all_records
to simply callget_records_subset
_validate_rows_ranges_for_get_records_subset
to validate the user inputs for (head, first_row, last_row
)_validate_headers_and_keys_for_get_records_subset
to do the following:expected_headers
given by the user are uniqueexpected_headers
_pad_values_and_keys_for_get_records_subset
to match the size of the keys and rows, to produce dictionaries as expected.