-
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
PROPOSAL: changes to get_records
/get_all_records
#1367
Comments
Should we get started on this ? I propose:
after that then:
What do you think ?
|
sounds good to me :) let me read what I wrote 3 weeks ago to remember what we're doing... ;) I should make edits to |
you should start you branch from So far to me we have everything for v5, we don't change anything anymore. We need to apply the new changes on v6.0.0 for the method |
Add a new util function that helps building record values. Records are list of dictionaries, each dictionary has the same set of keys, they are set from the given list of headers. Each key is associated to a value from the given matrix of values. They are as many dictionaries as they are lines in the matrix. Each line in the matrix will be associated to a dictionary, each key is associated to a value from that line in the given order. Example: Headers: A B C Values: 1 2 3 7 8 9 Result: [ { A: 1, B: 2, C: 3}, {A: 7, B: 8, C: 9}] closes #1367 Signed-off-by: Alexandre Lavigne <[email protected]>
Add a new util function that helps building record values. Records are list of dictionaries, each dictionary has the same set of keys, they are set from the given list of headers. Each key is associated to a value from the given matrix of values. They are as many dictionaries as they are lines in the matrix. Each line in the matrix will be associated to a dictionary, each key is associated to a value from that line in the given order. Example: Headers: A B C Values: 1 2 3 7 8 9 Result: [ { A: 1, B: 2, C: 3}, {A: 7, B: 8, C: 9}] closes #1367 Signed-off-by: Alexandre Lavigne <[email protected]>
Add a new util function that helps building record values. Records are list of dictionaries, each dictionary has the same set of keys, they are set from the given list of headers. Each key is associated to a value from the given matrix of values. They are as many dictionaries as they are lines in the matrix. Each line in the matrix will be associated to a dictionary, each key is associated to a value from that line in the given order. Example: Headers: A B C Values: 1 2 3 7 8 9 Result: [ { A: 1, B: 2, C: 3}, {A: 7, B: 8, C: 9}] closes #1367 Signed-off-by: Alexandre Lavigne <[email protected]>
Add a new util function that helps building record values. Records are list of dictionaries, each dictionary has the same set of keys, they are set from the given list of headers. Each key is associated to a value from the given matrix of values. They are as many dictionaries as they are lines in the matrix. Each line in the matrix will be associated to a dictionary, each key is associated to a value from that line in the given order. Example: Headers: A B C Values: 1 2 3 7 8 9 Result: [ { A: 1, B: 2, C: 3}, {A: 7, B: 8, C: 9}] closes #1367 Signed-off-by: Alexandre Lavigne <[email protected]>
Add a new util function that helps building record values. Records are list of dictionaries, each dictionary has the same set of keys, they are set from the given list of headers. Each key is associated to a value from the given matrix of values. They are as many dictionaries as they are lines in the matrix. Each line in the matrix will be associated to a dictionary, each key is associated to a value from that line in the given order. Example: Headers: A B C Values: 1 2 3 7 8 9 Result: [ { A: 1, B: 2, C: 3}, {A: 7, B: 8, C: 9}] closes #1367 Signed-off-by: Alexandre Lavigne <[email protected]>
Add a new util function that helps building record values. Records are list of dictionaries, each dictionary has the same set of keys, they are set from the given list of headers. Each key is associated to a value from the given matrix of values. They are as many dictionaries as they are lines in the matrix. Each line in the matrix will be associated to a dictionary, each key is associated to a value from that line in the given order. Example: Headers: A B C Values: 1 2 3 7 8 9 Result: [ { A: 1, B: 2, C: 3}, {A: 7, B: 8, C: 9}] closes #1367 Signed-off-by: Alexandre Lavigne <[email protected]>
Add a new util function that helps building record values. Records are list of dictionaries, each dictionary has the same set of keys, they are set from the given list of headers. Each key is associated to a value from the given matrix of values. They are as many dictionaries as they are lines in the matrix. Each line in the matrix will be associated to a dictionary, each key is associated to a value from that line in the given order. Example: Headers: A B C Values: 1 2 3 7 8 9 Result: [ { A: 1, B: 2, C: 3}, {A: 7, B: 8, C: 9}] closes #1367 Signed-off-by: Alexandre Lavigne <[email protected]>
get_all_records
is a method which has provided much pain to maintain recently (issues #1363, #1355, #1354, #1352, #1294) (PRs #1364, #1357, #1345, #1343, #1301, #1028)We propose that we simplify the method, and reduce its scope.
New scope
Given a spreadsheet,
get_all_records
turns a header and following content into a list of recordsAPI information
The API call will return to the pre-5.12 case:
gspread/gspread/worksheet.py
Line 547 in 9cc862b
Even if the header is set to the 5th row, we still need to get all values, as we do not know the "final row" so we cannot use a row range like "5:999"
Features to be changed
Simplify the "duplicate headers" case
Features to be removed
get_records
method, i.e., range_specification.This means that headers + data will be obtained in a single API call. This simplifies a lot since we no longer have to pad the header/values to be the same length (#1357), as they will be the same length by nature of being from the same API call.
- get_records(first_index=10, last_index=15)
empty2zero
kwarg.Its job can be done by existing
default_blank
Details
Technically these differ currently.
default_blank
is used to replace a single blank header (not more), and also replace blank values. However, I think it should change to only replace values. Blank header should be left as-is and if there are multiple, duplicate headers can be ignored (see above).Features to be added
utils.to_records
Add a utils function to turn a list of headers + values into a list of dictionaries
implementation details
this will basically be a wrapper of
gspread/gspread/worksheet.py
Line 757 in 495a329
+ utils.to_records(header, values)
This can be put into documentation to tell people how to make their own list of records, given a header and values.
The text was updated successfully, but these errors were encountered: